Rename to SDC

This commit is contained in:
Anthony Wang 2022-10-20 00:33:23 -04:00
parent 87ea08e8f7
commit 6ea6f9c1c6
Signed by: a
GPG key ID: 42A5B952E6DD8D38
2 changed files with 7 additions and 7 deletions

View file

@ -1,25 +1,25 @@
# CD
# SDC
C port of [SD](https://git.exozy.me/Ta180m/SD), a very efficient flash cards app
C port of [SD](https://git.exozy.me/a/SD), a very efficient flash cards app
## Usage
Flash cards are stored in the `cards` table of a SQLite database. There are four columns: `idx INTEGER PRIMARY KEY, weight INTEGER, key STRING, val STRING`. The `idx` is a unique index for each card, starting at 0. The weight is how often the card should come up. The key and value are the front and reverse sides of the card. You can use the `sqlite3` CLI to create a card deck.
Now build this project with `gcc cd.c segmenttree.c -o cd -lsqlite3 -O2 -march=native` and run `./cd` to enjoy a fast flash cards experience! The program will display the `key` of a randomly selected card. Press any key to show the `val` of the card. Now press either `y` or `n` depending on whether you got the card correct, and the program adjusts that card's weight.
Now build this project with `gcc sd.c segmenttree.c -o sd -lsqlite3 -O2 -march=native` and run `./sd` to enjoy a fast flash cards experience! The program will display the `key` of a randomly selected card. Press any key to show the `val` of the card. Now press either `y` or `n` depending on whether you got the card correct, and the program adjusts that card's weight.
If you're wondering where the name came from, this is the C port of [SD](https://git.exozy.me/Ta180m/SD).
If you're wondering where the name came from, this is the C port of [SD](https://git.exozy.me/a/SD), which was named after a common type of flash card. 😀
## Performance
CD is designed to be extremely efficient in order to support a very large number of flash cards and should be able to handle millions of cards with ease. If `N` is the number of cards, initializing the program requires `O(N)` time and `O(N)` memory. Selecting a random card and adjusting its weight requires `O(log N)` time. Internally CD uses [segment trees](https://en.wikipedia.org/wiki/Segment_tree) to achieve this time complexity.
SD is designed to be extremely efficient in order to support a very large number of flash cards and should be able to handle millions of cards with ease. If `N` is the number of cards, initializing the program requires `O(N)` time and `O(N)` memory. Selecting a random card and adjusting its weight requires `O(log N)` time. Internally SD uses [segment trees](https://en.wikipedia.org/wiki/Segment_tree) to achieve this time complexity.
Some benchmark results using 10 card updates:
```
Benchmark 1: ./cd < test
C version: ./sd < test
Time (mean ± σ): 57.4 ms ± 4.5 ms [User: 6.9 ms, System: 2.4 ms]
Range (min … max): 51.9 ms … 70.9 ms 41 runs
Benchmark 2: ./sd < test
Go version: ./sd < test
Time (mean ± σ): 92.7 ms ± 6.8 ms [User: 8.4 ms, System: 4.5 ms]
Range (min … max): 79.4 ms … 108.9 ms 33 runs
```

View file