benchmarking

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

一世执手 提交于 2019-11-27 05:53:46
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") <bytecode: 0x069efeb8> <environment: namespace:base> as.POSIXlt function (x, tz = "", ...) UseMethod("as

Order of the code and performance

非 Y 不嫁゛ 提交于 2019-11-27 05:31:44
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 t2 := time.Since(t1) fmt.Println("Struct access time: : ", t2) a := make([]int, 4) t3 := time.Now() a[0] =

Multi-threading benchmarking issues

我是研究僧i 提交于 2019-11-27 05:22:55
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 separate csv file. My issue is that the average execution time for the sequential multiplication is a

Create quick/reliable benchmark with java?

家住魔仙堡 提交于 2019-11-27 05:12:31
I'm trying to create a benchmark test with java. Currently I have the following simple method: public static long runTest(int times){ long start = System.nanoTime(); String str = "str"; for(int i=0; i<times; i++){ str = "str"+i; } return System.nanoTime()-start; } I'm currently having this loop multiple times within another loop that is happening multiple times and getting the min/max/avg time it takes to run this method through. Then I am starting some activity on another thread and testing again. Basically I am just wanting to get consistent results... It seems pretty consistent if I have

What is an idiomatic way to have shared utility functions for integration tests and benchmarks?

北城余情 提交于 2019-11-27 04:48:49
问题 I have Rust project with both integration tests (in the /tests dir) and benchmarks (in the /benches dir). There are a couple of utility functions that I need in tests and benches, but they aren't related to my crate itself, so I can't just put them in the /utils dir. What is idiomatic way to handle this situation? 回答1: Create a shared crate (preferred) As stated in the comments, create a new crate. You don't have to publish the crate to crates.io . Just keep it as a local unpublished crate

std::chrono::clock, hardware clock and cycle count

为君一笑 提交于 2019-11-27 04:48:12
问题 std::chrono offer several clocks to measure times. At the same time, I guess the only way a cpu can evaluate time, is by counting cycles. Question 1: Does a cpu or a gpu has any other way to evaluate time than by counting cycles? If that is the case, because the way a computer count cycles will never be as precise as an atomic clock, it means that a "second" ( period = std::ratio<1> ) for a computer can be actually shorter or bigger than an actual second, causing differences in the long run

Java loop gets slower after some runs / JIT's fault?

ε祈祈猫儿з 提交于 2019-11-27 04:28:27
问题 So I wanted to benchmark some basic java functionality to add some imformation to this question: What is the gain from declaring a method as static. I know writing benchmarks is sometimes not easy but what happens here I cannot explain. Please note that I'm not interessted in how to fix this but on why this happens* The Test class: public class TestPerformanceOfStaticVsDynamicCalls { private static final long RUNS = 1_000_000_000L; public static void main( String [] args ){ new

get execution time in milliseconds in R

落花浮王杯 提交于 2019-11-27 04:25:45
问题 I have read a solution to this using tic(), toc() functions tic <- function(gcFirst = TRUE, type=c("elapsed", "user.self", "sys.self")) { type <- match.arg(type) assign(".type", type, envir=baseenv()) if(gcFirst) gc(FALSE) tic <- proc.time()[type] assign(".tic", tic, envir=baseenv()) invisible(tic) } toc <- function() { type <- get(".type", envir=baseenv()) toc <- proc.time()[type] tic <- get(".tic", envir=baseenv()) print(toc - tic) invisible(toc) } tic(); -----code---- toc(); elapsed 0.15

How many hardware details can a Java Applet Discover?

妖精的绣舞 提交于 2019-11-27 04:24:04
问题 I'm writing a Java applet to run differently under different hardware. For instance if I know a computer has a large amount of RAM but a weak processor, I can alter the balance of some time-memory trade-offs. Being able to discover the exact make and model of the CPU on which the applet is running could be helpful. Having such information would allow me to benchmark my software against different systems and find bottlenecks. Generally what I'm looking for is: Number of cores and/or processors

Slow AES GCM encryption and decryption with Java 8u20

早过忘川 提交于 2019-11-27 04:14:36
I am trying to encrypt and decrypt data using AES/GCM/NoPadding. I installed the JCE Unlimited Strength Policy Files and ran the (simple minded) benchmark below. I've done the same using OpenSSL and was able to achieve more than 1 GB/s encryption and decryption on my PC. With the benchmark below I'm only able to get 3 MB/s encryption and decryption using Java 8 on the same PC. Any idea what I am doing wrong? public static void main(String[] args) throws Exception { final byte[] data = new byte[64 * 1024]; final byte[] encrypted = new byte[64 * 1024]; final byte[] key = new byte[32]; final byte