benchmarking

How to really benchmark the memory usage of a Java application

痴心易碎 提交于 2019-12-06 02:54:12
问题 I want to compare different implementations of Java programs in terms of their memory usage efficiency. There are different usage scenarios formulated as JUnit test cases. Actually, all the code is open source at: https://github.com/headissue/cache2k-benchmark The general wisdom to get to the used memory of a Java program is this: Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() , of course it is also possible to use the JMX interface to get these values. However, the

How could this Java code be sped up?

二次信任 提交于 2019-12-05 23:54:57
I am trying to benchmark how fast can Java do a simple task: read a huge file into memory and then perform some meaningless calculations on the data. All types of optimizations count. Whether it's rewriting the code differently or using a different JVM, tricking JIT .. Input file is a 500 million long list of 32 bit integer pairs separated by a comma. Like this: 44439,5023 33140,22257 ... This file takes 5.5GB on my machine. The program can't use more than 8GB of RAM and can use only a single thread . package speedracer; import java.io.FileInputStream; import java.nio.MappedByteBuffer; import

What exactly is number of operations in JMH?

别说谁变了你拦得住时间么 提交于 2019-12-05 23:54:18
问题 The JavaDoc of annotation @OperationsPerInvocation in the Java Microbenchmarking Harness (JMH) states: value public abstract int value Returns: Number of operations per single Benchmark call. Default: 1 Being new to JMH I am wondering what type of operation (byte code operation, assembly code operation, Java operation etc) is meant here. This question naturally refers to all places in JMH (documentation, output, comments etc) where the term 'operation' is used (e.g. " operation/time " unit or

PHP microtime benchmark function time comparisons

只谈情不闲聊 提交于 2019-12-05 20:58:19
问题 I am currently using this function to benchmark some php scripts, the script gets the microtime it takes to execute, and writes it to a log on the server, but the problem i am having is that i have no idea what are some decent times. the script is below followed by some of my times, can anyone give me an idea on what kind of times i want to be within the range of? PLACE AT THE BEGINNING OF THE PAGE global $start_time; $start_time = microtime(); PLACE AT THE END OF THE PAGE global $start_time;

How long it takes for one second in Java? Measure latency time in Java

99封情书 提交于 2019-12-05 17:24:28
I don't want to change this code, I'm only interested in JVM, OS or kernel customization/configuration for best results! I have one second loop (1000 x 1ms) public static void main(String[] args) throws InterruptedException { long start = System.nanoTime(); for (int i = 0; i < 1000; i++ ) { Thread.sleep(TimeUnit.MILLISECONDS.toMillis(1)); } long duration = System.nanoTime() - start; System.out.println("Loop duration " + duration / TimeUnit.MILLISECONDS.toNanos(1) + " ms."); } On my Fedora 20 with kernel 3.12 this loop needs 1055 ms. This is pretty good result, average is more than 1100ms . Is

timing block of code in Python without putting it in a function

吃可爱长大的小学妹 提交于 2019-12-05 17:17:19
问题 I'd like to time a block of code without putting it in a separate function. for example: def myfunc: # some code here t1 = time.time() # block of code to time here t2 = time.time() print "Code took %s seconds." %(str(t2-t1)) however, I'd like to do this with the timeit module in a cleaner way, but I don't want to make a separate function for the block of code. thanks. 回答1: You can do this with the with statement. For example: import time from contextlib import contextmanager @contextmanager

Resources containing cross-language benchmarks?

喜夏-厌秋 提交于 2019-12-05 16:37:56
What resources are available that use benchmarks for comparing programming languages? I am interested in both How quickly a program in a given language can execute a given benchmark? How many lines of code are required in a given language to implement a given benchmark? There is a long-standing web site called the Computer Language Benchmarks Game , originally created by Doug Bagley as the "Great Computer Language Shootout". (You can view a little history at Portland Patterns Repository.) Is anyone aware of other resources that enable programmers to compare performance and size of programs

How to measure IOPS for a command in linux?

霸气de小男生 提交于 2019-12-05 15:33:52
问题 I'm working on a simulation model, where I want to determine when the storage IOPS capacity becomes a bottleneck (e.g. and HDD has ~150 IOPS, while an SSD can have 150,000). So I'm trying to come up with a way to benchmark IOPS in a command (git) for some of it's different operations (push, pull, merge, clone). So far, I have found tools like iostat, however, I am not sure how to limit the report to what a single command does. The best idea I can come up with is to determine my HDD IOPS

Measure precision of timer (e.g. Stopwatch/QueryPerformanceCounter)

做~自己de王妃 提交于 2019-12-05 15:26:38
Given that the Stopwatch class in C# can use something like three different timers underneath e.g. System timer e.g. precision of approx +-10 ms depending on timer resolution that can be set with timeBeginPeriod it can be approx +-1 ms . Time Stamp Counter (TSC) e.g. with a tick frequency of 2.5MHz or 1 tick = 400 ns so ideally a precision of that. High Precision Event Timer (HPET) e.g. with a tick frequency of 25MHz or 1 tick = 40 ns so ideally a precision of that. how can we measure the observable precision of this? Precision being defined as Precision refers to the closeness of two or more

Why is the first run always much slower?

喜欢而已 提交于 2019-12-05 13:04:23
I wrote a macro that reports the time required to run a given operation. It runs it a number of times and prints out the time for each run in nanoseconds. The first run always takes significantly more time than subsequent ones. Why is that so? Here are the results of 10 x 10 runs, timing Thread.yield() : > (dotimes [x 10] (prn (times 10 (Thread/yield)))) [55395 1659 622 561 591 702 795 719 742 624] [3255 772 884 677 787 634 605 664 629 657] [3431 789 965 671 774 767 627 627 521 717] [2653 780 619 632 616 614 606 602 629 667] [2373 759 700 676 557 639 659 654 659 676] [2884 929 627 604 689 614