benchmarking

Why does JMH run different forks?

僤鯓⒐⒋嵵緔 提交于 2019-12-18 14:52:39
问题 I am using the JMH benchmarking framework (http://openjdk.java.net/projects/code-tools/jmh/) to run benchmarks on my code. My understanding is that JMH forks the JVM multiple times during benchmarking in order to discard any profiles built up by the just-in-time (JIT) profiling performed by the JVM during execution. I understand why this is useful in some cases such as the below (copied verbatim from http://java-performance.info/jmh/): By default JHM forks a new java process for each trial

Has anyone done a performance analysis of boost::asio?

ⅰ亾dé卋堺 提交于 2019-12-18 12:18:56
问题 I require socket-like local IPC. I used named pipes and overlapped IO on windows and I want to rewrite the application to boost::ASIO so that it can use UNIX domain sockets as well. I've recently reviewed parts of the libevent library and I know it only supports socket() and select() for windows in the 1.4 version. As overlapped IO is very efficient leaving it out is obviously an unacceptable trait which is being adressed in version 2 (which is in alpha). Another example of sub-optimal

Python, using multiprocess is slower than not using it

邮差的信 提交于 2019-12-18 11:57:13
问题 After spending a lot of time trying to wrap my head around multiprocessing I came up with this code which is a benchmark test: Example 1: from multiprocessing import Process class Alter(Process): def __init__(self, word): Process.__init__(self) self.word = word self.word2 = '' def run(self): # Alter string + test processing speed for i in range(80000): self.word2 = self.word2 + self.word if __name__=='__main__': # Send a string to be altered thread1 = Alter('foo') thread2 = Alter('bar')

Why is == faster than eql?

扶醉桌前 提交于 2019-12-18 11:26:34
问题 I read in the documentation for the String class that eql? is a strict equality operator, without type conversion, and == is a equality operator which tries to convert second its argument to a String, and, the C source code for this methods confirms that: The eql? source code: static VALUE rb_str_eql(VALUE str1, VALUE str2) { if (str1 == str2) return Qtrue; if (TYPE(str2) != T_STRING) return Qfalse; return str_eql(str1, str2); } The == source code: VALUE rb_str_equal(VALUE str1, VALUE str2) {

Benchmarking method calls in C# [duplicate]

南笙酒味 提交于 2019-12-18 11:07:47
问题 This question already has answers here : Exact time measurement for performance testing [duplicate] (8 answers) Closed 6 years ago . I'm looking for a way to benchmark method calls in C#. I have coded a data structure for university assignment, and just came up with a way to optimize a bit, but in a way that would add a bit of overhead in all situations, while turning a O(n) call into O(1) in some. Now I want to run both versions against the test data to see if it's worth implementing the

How to benchmark functions in Clojure?

浪尽此生 提交于 2019-12-18 10:13:49
问题 I know I can get the time take to evaluate a function can be printed out on the screen/stdout using the time function/macro. The time macro returns the value of the evaluated function, which makes it great to use it inline. However I want to automatically measure the runtime under specific circumstances. Is there a function which returns the elapsed time in some library to help with this benchmarking? 回答1: You might want to look into Hugo Duncan's benchmarking library for Clojure -- Criterium

Same program faster on Linux than Windows — why?

一世执手 提交于 2019-12-18 06:51:26
问题 The solution to this was found in the question Executable runs faster on Wine than Windows -- why? Glibc's floor() is probably implemented in terms of system libraries. I have a very small C++ program (~100 lines) for a physics simulation. I have compiled it with gcc 4.6.1 on both Ubuntu Oneiric and Windows XP on the same computer. I used precisely the same command line options (same makefile). Strangely, on Ubuntu, the program finishes much faster than on Windows (~7.5 s vs 13.5 s). At this

Best practice when working with sparse matrices

痴心易碎 提交于 2019-12-18 04:38:25
问题 This question is based on a discussion in this question. I have been working with sparse matrices earlier and my belief is that the way I've been working with these is efficient. My question is twofold: In the below, A = full(S) where S is a sparse matrix. What's the "correct" way to access an element in a sparse matrix? That is, what would the sparse equivalent to var = A(row, col) be? My view on this topic: You wouldn't do anything different. var = S(row, col) is as efficient as it gets. I

High-Performance Timer vs StopWatch

对着背影说爱祢 提交于 2019-12-18 03:04:09
问题 Does anyone know if the HiPerfTimer or the StopWatch class is better for benchmarking, and why? 回答1: Stopwatch is based on High resolution timer (where available), you can check that with IsHighResolution 回答2: They are the same when it comes to high resolution timing. Both use this: [DllImport("Kernel32.dll")] private static extern bool QueryPerformanceCounter(out long PerformanceCount); and this: [DllImport("Kernel32.dll")] private static extern bool QueryPerformanceFrequency(out long

How to measure file read speed without caching?

 ̄綄美尐妖づ 提交于 2019-12-17 22:53:30
问题 My java program spends most time by reading some files and I want to optimize it, e.g., by using concurrency, prefetching, memory mapped files, or whatever. Optimizing without benchmarking is a non-sense, so I benchmark. However, during the benchmark the whole file content gets cached in RAM, unlike in the real run. Thus the run-times of the benchmark are much smaller and most probably unrelated to the reality. I'd need to somehow tell the OS (Linux) not to cache the file content, or better