Comments (7)
Will be included in celo-org/zexe#4 with the following interface:
let now = timing!();
dlsd_radixsort(bucket_positions, 8);
timing_println!(now, "radixsort");
and following output:
--features "timing"
[ radixsort ] 2168us
--features "timing_detailed"
batch_bucketed_add in bucketed_add.rs 50:51 [ radixsort ] 11532us
from std.
Code uses macros:
#[macro_export]
macro_rules! timing_println {
($now: ident, $string: expr) => {
#[cfg(feature = "timing")]
{
println!("[ {} ] {}us", $string, $now.1.elapsed().as_micros(),);
}
#[cfg(feature = "timing_detailed")]
{
macro_rules! function {
() => {{
fn f() {}
fn type_name_of<T>(_: T) -> &'static str {
core::any::type_name::<T>()
}
let name = type_name_of(f);
&name[..name.len() - 3]
}};
}
println!(
"{} in {} {}:{} [ {} ] {}us",
String::from(function!()).split("::").last().unwrap(),
String::from(file!()).split("/").last().unwrap(),
$now.0,
line!() - 1,
$string,
$now.1.elapsed().as_micros(),
);
}
};
}
#[macro_export]
macro_rules! timing {
() => {{
#[cfg(any(feature = "timing", feature = "timing_detailed"))]
let now = (line!(), std::time::Instant::now());
#[cfg(not(any(feature = "timing", feature = "timing_detailed")))]
let now = ();
now
}};
}
from std.
The next step is to use proc macros to define which specific invocation of a function ought to compile with timing instrumentation using an attribute like
#[timing(on)]
batch_affine_add(..)
#[timing(off)]
batch_affine_double(..)
from std.
This already exists with the bench-utils crate
from std.
Hmm I see. Thats cool. I will work on mine a bit and see if we can combine some features. One thing I can do is to identify the function in which the timer is called, so that one can blacklist functions from emiting log msgs
from std.
Longer term I plan to move to infrastructure based on tracing
, which would allow similar blacklisting (and has many more features to boot!)
from std.
Hmm looks really interesting, looking forward to using tracing!
from std.
Related Issues (13)
- WASM compilation/Webapp proof of concept HOT 2
- Investigate parallelization for wasm with `web_worker` HOT 1
- algebra_core::io module inconsistent with std::io HOT 9
- ark-std does not compile in `no_std` HOT 4
- What became of bench utils? HOT 1
- Add method for randomly sampling non-zero elements HOT 1
- Export `rand::Rng` from `ark_std::rand`
- A new README for utils HOT 1
- Rename `log2` to `log2_of_next_power_of_two`
- Replace `UniformRand` by `CryptoRng + R` HOT 1
- `ark_std::error` vs `core::error` HOT 3
- Infinite dot when some spawned thread crash which make indent more than 75 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from std.