microbenchmark

What's up with the “half fence” behavior of rdtscp?

蹲街弑〆低调 提交于 2020-05-26 04:42:10
问题 For many years x86 CPUs supported the rdtsc instruction, which reads the "time stamp counter" of the current CPU. The exact definition of this counter has changed over time, but on recent CPUs it is a counter that increments at a fixed frequency with respect to wall clock time, so it is very useful as building block for a fast, accurate clock or measuring the time taken by small segments of code. One important fact about the rdtsc instruction isn't ordered in any special way with the

What's up with the “half fence” behavior of rdtscp?

为君一笑 提交于 2020-05-26 04:41:23
问题 For many years x86 CPUs supported the rdtsc instruction, which reads the "time stamp counter" of the current CPU. The exact definition of this counter has changed over time, but on recent CPUs it is a counter that increments at a fixed frequency with respect to wall clock time, so it is very useful as building block for a fast, accurate clock or measuring the time taken by small segments of code. One important fact about the rdtsc instruction isn't ordered in any special way with the

Why is substr-lvalue faster than four-arg substr?

旧城冷巷雨未停 提交于 2020-05-15 07:29:07
问题 From this question, we benchmark these two variants, substr( $foo, 0, 0 ) = "Hello "; substr( $foo, 0, 0, "Hello " ); In it we discover that substr -lvalue is faster . To which Ikegami said, How is 4-arg substr slower than lvalue substr (which must create a magical scalar, and requires extra operations)??? – ikegami Truth be told, I also assumed that it would be massively slower and just mentioned it because it was brought up by someone else. Purely for curiosity, Why is substr -lvalue faster

“Escape” and “Clobber” equivalent in MSVC

时光怂恿深爱的人放手 提交于 2020-05-09 19:33:25
问题 In Chandler Carruth's CppCon 2015 talk he introduces two magical functions for defeating the optimizer without any extra performance penalties. For reference, here are the functions (using GNU-style inline assembly): void escape(void* p) { asm volatile("" : : "g"(p) : "memory"); } void clobber() { asm volatile("" : : : "memory"); } It works on any compiler which supports GNU-style inline assembly (GCC, Clang, Intel's compiler, possibly others). However, he mentions it doesn't work in MSVC.

Idiomatic way of performance evaluation?

血红的双手。 提交于 2020-04-17 23:30:39
问题 I am evaluating a network+rendering workload for my project. The program continuously runs a main loop: while (true) { doSomething() drawSomething() doSomething2() sendSomething() } The main loop runs more than 60 times per second. I want to see the performance breakdown, how much time each procedure takes. My concern is that if I print the time interval for every entrance and exit of each procedure, It would incur huge performance overhead. I am curious what is an idiomatic way of measuring

I don't understand the definition of DoNotOptimizeAway

余生颓废 提交于 2020-04-17 19:24:08
问题 I am checking on Celero git repository the meaning of DoNotOptimizeAway . But I still don't get it. Could you please help me understand it in layman's terms please. As much as you can. The celero::DoNotOptimizeAway template is provided to ensure that the optimizing compiler does not eliminate your function or code. Since this feature is used in all of the sample benchmarks and their baseline, it's time overhead is canceled out in the comparisons. 回答1: You haven't included the definition, just

Why Document.querySelector is more efficient than Element.querySelector

浪尽此生 提交于 2020-04-13 06:18:10
问题 I did a test with few iterations to test efficiency of Document.querySelector and Element.querySelector . Markup: <form> <input type="text" /> </form> Script: Querying with Document.querySelector begin = performance.now(); var i = 0, iterations = 999999; for ( i; i < iterations; i++ ) { element = document.querySelector('[type="text"]'); } end = performance.now(); firstResult = end - begin; Querying with Element.querySelector begin = performance.now(); var i = 0, iterations = 999999, form =

Why the bounds check doesn't get eliminated?

浪尽此生 提交于 2020-02-10 02:37:12
问题 I wrote a simple benchmark in order to find out if bounds check can be eliminated when the array gets computed via bitwise and. This is basically what nearly all hash tables do: They compute h & (table.length - 1) as an index into the table , where h is the hashCode or a derived value. The results shows that the bounds check don't get eliminated. The idea of my benchmark is pretty simple: Compute two values i and j , where both are guaranteed to be valid array indexes. i is the loop counter.

How to build and link google benchmark using cmake in windows

两盒软妹~` 提交于 2020-01-24 20:14:33
问题 I am trying to build google-benchmark and use it with my library using cmake. I have managed to build google-benchmark and run all its tests successfully using cmake. I am unfortunately unable to link it properly with my c++ code in windows using cmake or cl. the problem I think is that google-benchmark builds the library inside the src folder, i.e it is build in src/Release/benchmark.lib now i cannot point to it in cmake if I use ${benchmark_LIBRARIES} it looks for the library in the Release

Is there any difference in between (rdtsc + lfence + rdtsc) and (rdtsc + rdtscp) in measuring execution time?

假装没事ソ 提交于 2020-01-24 09:29:28
问题 As far as I know, the main difference in runtime ordering in a processor with respect to rdtsc and rdtscp instruction is that whether the execution waits until all previous instructions are executed locally. In other words, it means lfence + rdtsc = rdtscp because lfence preceding the rdtsc instruction makes the following rdtsc to be executed after all previous instruction finish locally. However, I've seen some example code that uses rdtsc at the start of measurement and rdtscp at the end.