bittnkr/uniq

Benchmarking uniQ vs postMessage in the browser:

Opened this issue · 2 comments

Originally posted by @slnovak in #3 (comment)
I ran some initial benchmarks of sending 1M events via postMessage vs. uniq in the browser:

On a 2017 Macbook Air and Chrome 80.0.3987.149:

Test Case (buffer size) Time to send 1M Time to receive 1M
postMessage 11.714 sec 13.460 sec
uniq (64) 11.065 sec 18.745 sec
uniq (512) 10.059 sec 12.903 sec
uniq (1024) 9.999 sec 12.871 sec

Feel free to take a look at the code for these benchmarks and let me know if you have any suggestions to change the testing approach.

https://github.com/slnovak/uniq-benchmark

Cheers!

Thanks for your considerations,

I ran your tests, and at first sight, I feel that the main reason because you found almost no difference uniQ and postMessage, is that you a are using a single channel of comunication.

I mean, there is just one producer and one consumer. Note that in my tests I've created at least 2 of each. Where uniQ realy shine is with multiple threads. (Testing on my crapy HP i7 notebook on Ubuntu , I got near 3 million flows (push & pop) per second using 4 threads)

I'll do some testing in browser and soon I send you the results.

Today I made a new benchmark (look at js/inbrowser) Got the following results:

sending 100,000 messages through postMessage
time: 3254 ms

sending 100,000 messages through Q.push()
time: 1253 ms

These benchmarks are for two way communication. (Back and forth)

It seem that uniQ is 2,7x faster than postMessage. But It should be much more faster.

With nodeJs I got 0,75s to flow a million messages, what make it 43x faster.

But the browser lacks the setImmediate function and using setTimeout make the thing really slower when the Queue got full or empty.