.toArray(new MyClass[0]) or .toArray(new MyClass[myList.size()])?

Counterintuitively, the fastest version, on Hotspot 8, is: MyClass[] arr = myList.toArray(new MyClass[0]); I have run a micro benchmark using jmh the results and code are below, showing that the version with an empty array consistently outperforms the version with a presized array. Note that if you can reuse an existing array of the correct … Read more

Can modern C++ get you performance for free?

I am aware of 5 general categories where recompiling a C++03 compiler as C++11 can cause unbounded performance increases that are practically unrelated to quality of implementation. These are all variations of move semantics. std::vector reallocate struct bar{ std::vector<int> data; }; std::vector<bar> foo(1); foo.back().data.push_back(3); foo.reserve(10); // two allocations and a delete occur in C++03 every … Read more

How to change the playing speed of videos in HTML5?

According to this site, this is supported in the playbackRate and defaultPlaybackRate attributes, accessible via the DOM. Example: /* play video twice as fast */ document.querySelector(‘video’).defaultPlaybackRate = 2.0; document.querySelector(‘video’).play(); /* now play three times as fast just for the heck of it */ document.querySelector(‘video’).playbackRate = 3.0; The above works on Chrome 43+, Firefox 20+, IE … Read more

Node.js vs .Net performance

Being FAST and handling lots of LOAD are two different things. A server that’s really FAST at serving one request per second might totally croak if you send it 500 requests per second (under LOAD). You also have to consider static (and cached) vs dynamic pages. If you’re worried about static pages, then IIS is … Read more