benchmarking

How do you time a function in Go and return its runtime in milliseconds?

邮差的信 提交于 2019-12-02 17:03:35
How do you time a function in Go and return its runtime in milliseconds? Use the Go testing package to benchmark the function. For example, package main import ( "fmt" "testing" ) // the function to be benchmarked func Function(n int) int64 { n64 := int64(n) return n64 * n64 } func BenchmarkFunction(b *testing.B) { n := 42 for i := 0; i < b.N; i++ { _ = Function(n) } } func main() { br := testing.Benchmark(BenchmarkFunction) fmt.Println(br) } Output: 500000000 4.22 ns/op You can also use the Go gotest command to run benchmarks. Go's defer makes this trivial. In Go 1.x, define the following

Anyone here has benchmarked Intel C++ compiler and GCC?

蹲街弑〆低调 提交于 2019-12-02 16:40:33
I am not sure whether I should post this question here, because this seems to be a programming-oriented website. Anyway, I think there must be some gurus here who knows this. Now I have a AMD Opteron server running CentOS 5. I want to have a compiler for a fairly large c++ Boost based program. Which compiler I should choose? I hope this helps more than hurts :) I did a little compiler shootout sometime over a year ago, and I am going off memory. GCC 4.2 (Apple) Intel 10 GCC 4.2 (Apple) + LLVM I tested multiple template heavy audio signal processing programs that I'd written. Compilation times:

Which gets the measurements right, JMeter or Apache ab?

依然范特西╮ 提交于 2019-12-02 16:37:01
I started writing some basic tests in JMeter and was surprised that the measurements are so different from those from Apache ab. I have a gigabit LAN connecting an Intel i7 server running Nginx and an i5 test machine running JMeter or ab. Initially, I am simply testing the out-of-the box Nginx home page response rate. ab -c 1 -n 100 http://testserver.local/ gives Document Path: / Document Length: 151 bytes Concurrency Level: 1 Time taken for tests: 0.078 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 38400 bytes HTML transferred: 15100 bytes Requests per

Quantifiable metrics (benchmarks) on the usage of header-only c++ libraries

折月煮酒 提交于 2019-12-02 16:05:12
I've tried to find an answer to this using SO. There are a number of questions that list the various pros and cons of building a header-only library in c++, but I haven't been able to find one that does so in quantifiable terms. So, in quantifiable terms, what's different between using traditionally separated c++ header and implementation files versus header only? For simplicity, I'm assuming that templates are not used (because they require header only). To elaborate, I've listed what I have seen from the articles to be the pros and cons. Obviously, some are not easily quantifiable (such as

Why does JavaScript appear to be 4 times faster than C++?

一个人想着一个人 提交于 2019-12-02 15:50:25
For a long time, I had thought of C++ being faster than JavaScript. However, today I made a benchmark script to compare the speed of floating point calculations in the two languages and the result is amazing! JavaScript appears to be almost 4 times faster than C++! I let both of the languages to do the same job on my i5-430M laptop, performing a = a + b for 100000000 times. C++ takes about 410 ms, while JavaScript takes only about 120 ms. I really do not have any idea why JavaScript runs so fast in this case. Can anyone explain that? The code I used for the JavaScript is (run with Node.js):

Load Testing and Benchmarking With siege vs wrk

∥☆過路亽.° 提交于 2019-12-02 15:18:12
I have been looking around for tools that can help me to do load testing and benchmarking. I found couples like: https://github.com/wg/wrk , http://www.joedog.org/siege-home/ , https://github.com/rakyll/boom . I'm wondering if anyone has any experience with these tools and have any feedback pros vs cons of these tools. My load stress will include different test cases using DELETE, PUT, GET, POST... headers Thanks I've used wrk and siege, siege is a really easy to use tool, but I'm not sure if you can test DELETE or PUT with siege. Wrk can use provided lua script to generate requests, so DELETE

Measure and Benchmark Time for Ruby Methods

淺唱寂寞╮ 提交于 2019-12-02 15:01:40
How can i measure the time taken by a method and the individual statements in that method in Ruby. If you see the below method i want to measure the total time taken by the method and the time taken for database access and redis access. I do not want to write Benchmark.measure before every statement. Does the ruby interpreter gives us any hooks for doing this ? def foo # code to access database # code to access redis. end You could use the Time object. ( Time Docs ) For example, start = Time.now # code to time finish = Time.now diff = finish - start diff would be in seconds, as a floating

Generate line graph for any benchmark?

萝らか妹 提交于 2019-12-02 14:49:36
问题 I had spent so many hours failing to find a line graph generator for my benchmark results that I just wanted to plug in. I tried quite a few like Google's chart API but it still seemed confusing or not graceful looking, I am clueless. Examples of benchmark images I wished to make something like are this: What specific applications /web services do you recommend for generating something even close to this? I want something "neat". 回答1: You can use python mathplotlib, which generates beautiful

Generate line graph for any benchmark?

て烟熏妆下的殇ゞ 提交于 2019-12-02 08:14:37
I had spent so many hours failing to find a line graph generator for my benchmark results that I just wanted to plug in. I tried quite a few like Google's chart API but it still seemed confusing or not graceful looking, I am clueless. Examples of benchmark images I wished to make something like are this: What specific applications /web services do you recommend for generating something even close to this? I want something "neat". You can use python mathplotlib , which generates beautiful graphs like: (Source code) I use gnuplot . It is not a lib, but a separate executable file. You can output

How to invalidate cache when benchmarking?

你说的曾经没有我的故事 提交于 2019-12-02 06:35:57
I have this code, that when swapping the order of UsingAs and UsingCast, their performance also swaps. using System; using System.Diagnostics; using System.Linq; using System.IO; class Test { const int Size = 30000000; static void Main() { object[] values = new MemoryStream[Size]; UsingAs(values); UsingCast(values); Console.ReadLine(); } static void UsingCast(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { if (o is MemoryStream) { var m = (MemoryStream)o; sum += (int)m.Length; } } sw.Stop(); Console.WriteLine("Cast: {0} : {1}", sum, (long)sw