otobrglez / compression-puzzle

Attempts to crack the "compression puzzle".
15 stars 47 forks source link

Add C++ examples #43

Closed inejc closed 2 years ago

inejc commented 2 years ago

Adding an imperative example (compress_fast) and a more functional one (compress_slow). The functional one could be optimized further as the accumulate currently does a bunch of copies internally + string concatenations do copies too :).

Anyway, here are mean timings for a 20000 chars long string (averaged over 5k iterations):

./src/c++/compress_slow
compress_slow mean time: 5.10957ms
./src/c++/compress_fast
compress_fast mean time: 0.107779ms
otobrglez commented 2 years ago

O, man! I miss reviewing your code.

Thanks @inejc for taking the time and look into this challenge and play with us! I LOVE IT!

I hope u are not too cold up on the north and hope we catch up soon!

Regards!

P.s.: I'll make attributions/credit change in separate push.