benchmarking

Java benchmarking - why is the second loop faster?

妖精的绣舞 提交于 2019-11-26 17:31:33
问题 I'm curious about this. I wanted to check which function was faster, so I create a little code and I executed a lot of times. public static void main(String[] args) { long ts; String c = "sgfrt34tdfg34"; ts = System.currentTimeMillis(); for (int k = 0; k < 10000000; k++) { c.getBytes(); } System.out.println("t1->" + (System.currentTimeMillis() - ts)); ts = System.currentTimeMillis(); for (int i = 0; i < 10000000; i++) { Bytes.toBytes(c); } System.out.println("t2->" + (System.currentTimeMillis

How to load data quickly into R?

我与影子孤独终老i 提交于 2019-11-26 15:18:45
问题 I have some R scripts, where I have to load several dataframe in R as quickly as possible. This is quite important as reading the data is the slowest part of the procedure. E.g.: plotting from different dataframes. I get the data in sav (SPSS) format, but I could transform it to any format as suggested. Merging the dataframes is not an option unfortunately. What could be the fastest way to load the data? I was thinking of the following: transform from sav to binary R object ( Rdata ) in the

Why is json.loads an order of magnitude faster than ast.literal_eval?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 14:16:45
问题 After answering a question about how to parse a text file containing arrays of floats, I ran the following benchmark: import timeit import random line = [random.random() for x in range(1000)] n = 10000 json_setup = 'line = "{}"; import json'.format(line) json_work = 'json.loads(line)' json_time = timeit.timeit(json_work, json_setup, number=n) print "json: ", json_time ast_setup = 'line = "{}"; import ast'.format(line) ast_work = 'ast.literal_eval(line)' ast_time = timeit.timeit(ast_work, ast

What is microbenchmarking?

北城以北 提交于 2019-11-26 12:59:17
I've heard this term used, but I'm not entirely sure what it means, so: What DOES it mean and what DOESN'T it mean? What are some examples of what IS and ISN'T microbenchmarking? What are the dangers of microbenchmarking and how do you avoid it? (or is it a good thing?) In silico It means exactly what it says on the tin can - it's measuring the performance of something "small", like a system call to the kernel of an operating system. The danger is that people may use whatever results they obtain from microbenchmarking to dictate optimizations. And as we all know: We should forget about small

What does “an intermediate result is being cached” mean?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 12:29:47
问题 I have a set of n vectors stored in the 3 x n matrix z . I find the outer product using np.einsum . When I timed it using: %timeit v=np.einsum(\'i...,j...->ij...\',z,z) I got the result: The slowest run took 7.23 times longer than the fastest. This could mean that an intermediate result is being cached 100000 loops, best of 3: 2.9 µs per loop What is happening here and can it be avoided? The best 3 is 2.9us, but the slowest maybe more typical. 回答1: The message "intermediate result is being

How much faster is C++ than C#?

北城余情 提交于 2019-11-26 12:15:45
问题 Or is it now the other way around? From what I\'ve heard there are some areas in which C# proves to be faster than C++, but I\'ve never had the guts to test it by myself. Thought any of you could explain these differences in detail or point me to the right place for information on this. 回答1: There is no strict reason why a bytecode based language like C# or Java that has a JIT cannot be as fast as C++ code. However C++ code used to be significantly faster for a long time, and also today still

What is FLOP/s and is it a good measure of performance?

て烟熏妆下的殇ゞ 提交于 2019-11-26 11:56:52
问题 I\'ve been asked to measure the performance of a fortran program that solves differential equations on a multi-CPU system. My employer insists that I measure FLOP/s (Floating operations per second) and compare the results with benchmarks (LINPACK) but I am not convinced that it\'s the way to go, simply because no one can explain to me what a FLOP is. I did some research on what exactly a FLOP is and I got some pretty contradicting answers. One of the most popular answers I got was \'1 FLOP =

Difference between as.POSIXct/as.POSIXlt and strptime for converting character vectors to POSIXct/POSIXlt

谁说胖子不能爱 提交于 2019-11-26 11:46:51
问题 I have followed a number of questions here that asks about how to convert character vectors to datetime classes. I often see 2 methods, the strptime and the as.POSIXct/as.POSIXlt methods. I looked at the 2 functions but am unclear what the difference is. strptime function (x, format, tz = \"\") { y <- .Internal(strptime(as.character(x), format, tz)) names(y$year) <- names(x) y } <bytecode: 0x045fcea8> <environment: namespace:base> as.POSIXct function (x, tz = \"\", ...) UseMethod(\"as.POSIXct

Order of the code and performance

大城市里の小女人 提交于 2019-11-26 11:36:59
问题 I wanted to find which is faster: struct vs array. So I wrote a GO code in which I write 4 int values (1,2,3 and 4) to the members of a structure and then to an array of length 4. I tried to find the time it takes to write. Case1: First, I write values to a structure and then to an array. Here I found array to be faster than structure. package main import ( \"fmt\" \"time\" ) type abc struct { a, b, c, d int } func main() { var obj abc t1 := time.Now() obj.a = 1 obj.b = 2 obj.c = 3 obj.d = 4

Multi-threading benchmarking issues

让人想犯罪 __ 提交于 2019-11-26 11:33:17
问题 I have written a code that randomly generates two matrices from dimensions 2x2 up to 50x50. I am then recording the time it takes for each matrix multiplication from dimensions 2 up to 50. I record this time 100 times to get a good average for each case 2 -50. The program first starts off by multiplying the matrices sequentially and records the average execution time in a csv file. It then moves on to parallel matrix multiplication using pthreads and records the average execution times in a