Weird performance increase in simple benchmark

There is a very simple way to always get the “fast” version of your program. Project > Properties > Build tab, untick the “Prefer 32-bit” option, ensure that the Platform target selection is AnyCPU. You really don’t prefer 32-bit, unfortunately is always turned on by default for C# projects. Historically, the Visual Studio toolset worked … Read more

How efficient can Meteor be while sharing a huge collection among many clients?

The short answer is that only new data gets sent down the wire. Here’s how it works. There are three important parts of the Meteor server that manage subscriptions: the publish function, which defines the logic for what data the subscription provides; the Mongo driver, which watches the database for changes; and the merge box, … Read more

Why is splitting a string slower in C++ than Python?

As a guess, Python strings are reference counted immutable strings, so that no strings are copied around in the Python code, while C++ std::string is a mutable value type, and is copied at the smallest opportunity. If the goal is fast splitting, then one would use constant time substring operations, which means only referring to … Read more

Difference between as.POSIXct/as.POSIXlt and strptime for converting character vectors to POSIXct/POSIXlt

Well, the functions do different things. First, there are two internal implementations of date/time: POSIXct, which stores seconds since UNIX epoch (+some other data), and POSIXlt, which stores a list of day, month, year, hour, minute, second, etc. strptime is a function to directly convert character vectors (of a variety of formats) to POSIXlt format. … Read more

Is there any simple way to benchmark Python script?

Have a look at timeit, the python profiler and pycallgraph. Also make sure to have a look at the comment below by nikicc mentioning “SnakeViz”. It gives you yet another visualisation of profiling data which can be helpful. timeit def test(): “””Stupid test function””” lst = [] for i in range(100): lst.append(i) if __name__ == … Read more

Why is Go so slow (compared to Java)?

The 6g and 8g compilers are not particularly optimising, so the code they produce isn’t particularly fast. They’re designed to run fast themselves and produce code that’s OK (there is a bit of optimisation). gccgo uses GCC’s existing optimisation passes, and might provide a more pointful comparison with C, but gccgo isn’t feature-complete yet. Benchmark … Read more

LINQ Ring: Any() vs Contains() for Huge Collections

Contains() is an instance method, and its performance depends largely on the collection itself. For instance, Contains() on a List is O(n), while Contains() on a HashSet is O(1). Any() is an extension method, and will simply go through the collection, applying the delegate on every object. It therefore has a complexity of O(n). Any() … Read more

How can I benchmark JavaScript code? [closed]

jsperf.com is the go-to site for testing JS performance. Start there. If you need a framework for running your own tests from the command line or scripts use Benchmark.js, the library upon which jsperf.com is built. Note: Anyone testing Javascript code should educate themselves on the pitfalls of “microbenchmarks” (small tests that target a specific … Read more