benchmarking

How do I get monotonic time durations in python?

女生的网名这么多〃 提交于 2019-12-17 04:25:49
问题 I want to log how long something takes in real walltime. Currently I'm doing this: startTime = time.time() someSQLOrSomething() print "That took %.3f seconds" % (time.time() - startTime) But that will fail (produce incorrect results) if the time is adjusted while the SQL query (or whatever it is) is running. I don't want to just benchmark it. I want to log it in a live application in order to see trends on a live system. I want something like clock_gettime(CLOCK_MONOTONIC,...), but in Python.

How can I accurately benchmark unaligned access speed on x86_64

寵の児 提交于 2019-12-17 04:02:13
问题 In an answer, I've stated that unaligned access has almost the same speed as aligned access a long time (on x86/x86_64). I didn't have any numbers to back up this statement, so I've created a benchmark for it. Do you see any flaws in this benchmark? Can you improve on it (I mean, to increase GB/sec, so it reflects the truth better)? #include <sys/time.h> #include <stdio.h> template <int N> __attribute__((noinline)) void loop32(const char *v) { for (int i=0; i<N; i+=160) { __asm__ ("mov (%0),

Why is looping over range() in Python faster than using a while loop?

六眼飞鱼酱① 提交于 2019-12-17 03:27:06
问题 The other day I was doing some Python benchmarking and I came across something interesting. Below are two loops that do more or less the same thing. Loop 1 takes about twice as long as loop 2 to execute. Loop 1: int i = 0 while i < 100000000: i += 1 Loop 2: for n in range(0,100000000): pass Why is the first loop so much slower? I know it's a trivial example but it's piqued my interest. Is there something special about the range() function that makes it more efficient than incrementing a

How to measure code performance in .NET?

感情迁移 提交于 2019-12-17 03:05:07
问题 I'm doing some real quick and dirty benchmarking on a single line of C# code using DateTime: long lStart = DateTime.Now.Ticks; // do something long lFinish = DateTime.Now.Ticks; The problem is in the results: Start Time [633679466564559902] Finish Time [633679466564559902] Start Time [633679466564569917] Finish Time [633679466564569917] Start Time [633679466564579932] Finish Time [633679466564579932] ...and so on. Given that the start and finish times are identical, Ticks is obviously not

How to benchmark efficiency of PHP script

旧巷老猫 提交于 2019-12-16 23:02:36
问题 I want to know what is the best way to benchmark my PHP scripts. Does not matter if a cron job, or webpage or web service. I know i can use microtime but is it really giving me the real time of a PHP script? I want to test and benchmark different functions in PHP that do the same thing. For example, preg_match vs strpos or domdocument vs preg_match or preg_replace vs str_replace` Example of a webpage: <?php // login.php $start_time = microtime(TRUE); session_start(); // do all my logic etc...

OpenMP benchmark: Am I doing it right?

Deadly 提交于 2019-12-14 03:15:46
问题 I made a program which calculates the fibonacci sequence. I executed it with different numbers of threads (eg. 1, 2, 10) but the execution time remained almost the same (about 0.500 seconds). I'm using CodeBlocks on Ubuntu and the GNU GCC compiler. In CodeBlocks I linked the library gomp and defined the flag -fopenmp for the compiler. #include <omp.h> #include <stdio.h> #include <stdlib.h> int main() { int i, n=1000, a[n]; omp_set_num_threads(4); for(i=0; i<n; i++) { a[i] = 1 + (rand() % ( 50

How can I time processing of chunk of code using MT template language?

纵饮孤独 提交于 2019-12-14 03:01:50
问题 Often when developing a Movable Type template, I come up with multiple ways to generate the same result, and am curious which is more efficient. Or, I simply want to know how long something took, such as generating search results. Is there an easy way to recording processing time or other timing strategies using template tags without requiring external tools? 回答1: Or you could use the debug mode 8 as explained here: http://www.movabletype.org/documentation/developer/plugins/debug-mode.html

Indexing sequence to use for addressing an element of a data frame

一曲冷凌霜 提交于 2019-12-13 18:41:21
问题 There a several ways to access a specific element in a data frame, using various combinations of brackets ( [ ] ), and dollar signs ( $ ). In time-sensitive functions, which one to use can be important? Benchmarking some of the possible combinations: library(microbenchmark) df <- data.frame(a=1:6,b=1:6,c=1:6,d=1:6,e=1:6,f=1:6) microbenchmark(df$c[3], df[3,]$c, df[3,3], df[3,][3], df[3,][[3]], df[,3][3], times=1e3) yields these timings: Unit: microseconds expr min lq mean median uq max neval

MATLAB function is slow the first time, but much faster subsequently. Why?

我的未来我决定 提交于 2019-12-13 18:15:29
问题 I have a large MATLAB function file. It first creates a zero matrix, then updates about 70% of the cells by evaluating a number of corresponding (long) algebraic expressions that are hard coded in the function. Once this is complete, a numeric matrix is returned. The .m file is about 4 MB large (I have 100 of these m. files, but that is not directly relevant). When I evaluate the function the first time, it takes about 9 seconds to evaluate. Subsequent runs, however, only take about 0.1

Benchmark cp + git on linux v.s. Windows: why such differences?

て烟熏妆下的殇ゞ 提交于 2019-12-13 15:53:20
问题 I have created a large amount of files using this Python script that I used primarily to benchmark Git. The result is very surprising especially the differences between Windows and Linux. Basically my script creates 12 directories with 512 files in each of them. Each file is about 2 to 4 kB. With the Git objects the repository is about 12k files. I benchmarked: Time to add all the files to git git add . Time to checkout a previous branch Time to copy the repository on the same SSD Time to