POST request with wrk?

This is possible now. Here is an example https://github.com/wg/wrk/blob/master/scripts/post.lua. wrk.method = “POST” wrk.body = “foo=bar&baz=quux” wrk.headers[“Content-Type”] = “application/x-www-form-urlencoded” save this in a *.lua script and pass it into your command line test with the -s flag.

How to test only one benchmark function?

Description of testing flags -test.bench pattern Run benchmarks matching the regular expression. By default, no benchmarks run. -test.run pattern Run only those tests and examples matching the regular expression. For convenience, each of these -test.X flags of the test binary is also available as the flag -X in ‘go test‘ itself. For help, $ go … Read more

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

Go’s defer makes this trivial. In Go 1.x, define the following functions: func trace(s string) (string, time.Time) { log.Println(“START:”, s) return s, time.Now() } func un(s string, startTime time.Time) { endTime := time.Now() log.Println(” END:”, s, “ElapsedTime in seconds:”, endTime.Sub(startTime)) } After that, you get Squeaky Clean one line elapsed time log messages: func someFunction() … Read more

Why is 2 * x * x faster than 2 * ( x * x ) in Python 3.x, for integers?

First of all, note that we don’t see the same thing in Python 2.x: >>> timeit(“for i in range(1000): 2*i*i”) 51.00784397125244 >>> timeit(“for i in range(1000): 2*(i*i)”) 50.48330092430115 So this leads us to believe that this is due to how integers changed in Python 3: specifically, Python 3 uses long (arbitrarily large integers) everywhere. For … Read more

How to benchmark functions in Clojure?

If it’s just a matter of wanting to capture the string programmatically, you can bind *out* to something else before using time. user=> (def x (with-out-str (time (+ 2 2)))) #’user/x user=> x “\”Elapsed time: 0.119 msecs\”\n” If you want more control over the format, then you can create your own version of time using … Read more

How to benchmark programs in Rust?

It might be worth noting two years later (to help any future Rust programmers who stumble on this page) that there are now tools to benchmark Rust code as a part of one’s test suite. (From the guide link below) Using the #[bench] attribute, one can use the standard Rust tooling to benchmark methods in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)