Skip to content

Commit

Permalink
Reviewed section in performance.md and checked subtraction and string…
Browse files Browse the repository at this point in the history
… constructor in roadmap
  • Loading branch information
SomedudeX committed May 7, 2024
1 parent f3ffba4 commit 14bf017
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/pages/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ int main() {
Below is a list of features planned for this library. The checkmark next to them represents their rough status in development (a checkmark means that it is already implemented, no checkmark means that the feature is currently being worked on). This roadmap is only a rough to-do list for this repository, and may change without notice at any point in time.

- [x] Integer addition
- [ ] Integer subtraction
- [x] Integer subtraction
- [ ] Integer multiplication
- [ ] Integer division
- [ ] Integer `std::string` constructor
- [ ] Integer modulo operator
- [x] Integer `std::string` constructor
- [x] Integer conversion methods

Below is a list of features that is not currently being worked on, however may be added to the repository.

- [ ] Floating point numbers
- [ ] Integer modulo operator
- [ ] Integer math functions

## About
Expand Down
12 changes: 7 additions & 5 deletions docs/pages/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ add_end = time.perf_counter_ns()
print(f"Addition took {(add_end - add_beg) / 1000:.0f}ms")
```

The following chart shows the performance difference between the vint library and Python's int object when N grows. To ensure that no performance has been lost from real time interpreting, the Python script has been saved on disk and therefore compiled into bytecode before its run. The right most column showcases the performance difference between vint library and Python in percentage (e.g. `+55%` means that the vint library is 55% faster than Python). Note the time shown is a winsorized average of 5 test runs.
The following chart shows the performance difference between the vint library and Python's int object when N grows. To ensure that no performance has been lost from real time interpreting, the Python script has been saved on disk and therefore compiled into bytecode before its run. The right most column showcases the performance difference between vint library and Python in percentage (e.g. `+55%` means that the vint library is 55% faster than Python, and `-6.4x` means that vint is 6400% slower than Python). Note the time shown is a winsorized average of 5 test runs.

| N | Vint addition | Python addition | Difference |
|:----------|-----------------:|-------------------:|-------------:|
| 1,000 | 56μs | 82μs | +46% |
| 10,000 | 1,909µs | 2,517µs | +31% |
| 100,000 | 141ms | 177ms | +26% |
| 1,000 | 131μs | 82μs | -59% |
| 10,000 | 3,264µs | 2,517µs | -29% |
| 100,000 | 158ms | 177ms | +11% |
| 1,000,000 | 14,188ms | 17,474ms | +23% |

Of course, smaller values of N (and time) should always be taken with a grain of salt, since the overhead from the various operating system processes as well as the timer itself would cause the end result to be unreliable.

## Conversion Performance

Because conversion to string is the only way to print without integer overflow in c++, the conversion performance will be focused on only integer to string conversion. We can use the `to_string()` methods for vint or the `str()` function for Python. The following chart shows the performance differences between vint and Python in conversion from integer to string type. The leftmost column depicts the numbers of digits in base-10 that the number has:
Expand All @@ -58,6 +60,6 @@ Because conversion to string is the only way to print without integer overflow i
| 300 | 54μs | 2μs | -27.00x |
| 3,000 | 3,314μs | 123μs | -26.94x |
| 30,000 | 309ms | 8ms | -38.62x |
| 300,000 | 35,341ms | 29ms | -1218.65x |
| 300,000 | 34,641ms | 29ms | -1194.52x |

As one can tell, vint's integer to string conversion function is exponentially slower than Python's implementation. This is one area (who knew) that vint could improve.

0 comments on commit 14bf017

Please sign in to comment.