dterei / gotsc Goto Github PK
View Code? Open in Web Editor NEWGolang package providing access to TSC on x86-64
License: Other
Golang package providing access to TSC on x86-64
License: Other
I'm not familiar with the GO language, but reading the TSCOverhead function, it looks like the loop also makes calculations. Again, not sure, but I think a more precise overhead might be calculated if the returned values of calling Benchstart and Benchend are stored in an array first, and differences between t0 and t1 would only be calculated after the the loop of calling Benchstart and Benchend finishes. Assuming placing the return values in an array is faster then an if-test with a substract-calculation + another substract calculation to store it.
So my suggestion (or actually my question if it would be better) would be to let this function have two loops, where the first one calls the Benchstart and Benchend functions and the second loop processes the array results.
This
for i := 0; i < 100000; i++ {
t0 = BenchStart()
t1 = BenchEnd()
if t1-t0 < overhead {
overhead = t1 - t0
}
}
would become (something like) this, if 2 seperate arrays would be used:
for i := 0; i < 100000; i++ {
arStarts(i) = BenchStart() 'both in separate arrays, as using 2D array might be more costly (and separate arrays ensures the order of calling the functions?)
arEnds(i) = BenchEnd()
}
for i := 0; i < 100000; i++ {
t0 = arStarts(i) //BenchStart() returned value
t1 = arEnds(i) //BenchEnd() returned value
if t1-t0 < overhead {
overhead = t1 - t0
}
}
Or store in 2D array. I don't know about Go, but in some languages all arguments are evaluated first, before doing anything with it (fe VBA). It would mean that using an array won't cause any overhead (of storing value in array) at all:
for i := 0; i < 100000; i++ {
ar(i) = (BenchStart(), BenchEnd())
}
for i := 0; i < 100000; i++ {
t0 = a(i, 0) //BenchStart() returned value
t1 = ar(i, 1) //BenchEnd() returned value
if t1-t0 < overhead {
overhead = t1 - t0
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.