Comments (7)
Yes - I had always planned to add floating point support to num-format, but it's a bit more complicated than integers. I'd like to read and (at least partially) understand some of the following kind of stuff before I get started (just a sample of various stuff on the topic that's out there):
- https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
- https://github.com/miloyip/dtoa-benchmark
- https://github.com/dtolnay/dtoa
- rust-lang/rust#24556
But if inferno needs it, I'd be happy to prioritize the feature!
Doing a very naive implementation, by the way, would be super easy, but it would be just that, a very naive implementation. But if you wanted a temporary stop-gap feature added, I could do the naive version quickly while I work on implementing a faster algorithm for later release.
from inferno.
I did an initial implementation of this and realized that the output sometimes differs between my version and the Perl version because of differences in the way floating point numbers are rounded when formatting to a string compared to calling round
on an f64
.
712.5f64.round() as usize
results in 713
, but print!("{:.0}", 712.5);
prints 712
.
The Perl version formats the samples like this:
my $samples = sprintf "%.0f", ($etime - $stime) * $factor;
But our version is using num_format
, which doesn't support formatting floating point values. Currently I'm doing this before formatting:
let samples = ((frame.end_time - frame.start_time) as f64 * opt.factor).round() as usize;
Do we want to come up with a way to get the sample counts to match the Perl version in every case, or should we not worry about it?
from inferno.
I think we specifically need the result to not be a usize
, since factor
may be something like 0.01
. @bcmyers any plans to add support for floating point numbers to num-format
?
from inferno.
The Perl version formats the samples in the end without the fractional part. Are you saying you want to diverge from this behavior? If so, how many decimal places would we want to show?
from inferno.
Ohh, you're entirely right! I misread that part of the Perl code. I think what we want here is f64::floor
or f64::trunc
(not sure how they're different), both of which would exactly match the Perl version. Let's continue discussion in #65.
from inferno.
@bcmyers thanks, I appreciate that, but from the discussion above I think it's fine for us to just convert to an integer and then format, as that's what the Perl implementation is doing :)
from inferno.
Sounds good.
from inferno.
Related Issues (20)
- Color diffusion mode gives less useful results in flamechart mode HOT 2
- Support for simplifying recursive function calls as stackcollapse perl scripts HOT 7
- Support for collapsing source lines from -F+srcline in `perf script` outputs HOT 1
- atty 0.2 has a potential unaligned read HOT 3
- 0.11.15 build fails on Rust 1.62 HOT 1
- Single stack detection can be wrong if the event contains multiple colon HOT 3
- `Input data ends in the middle of a stack.` when using on result of attaching HOT 1
- Differential output tooltips are confusing HOT 4
- Differential output only calculates diff correctly for leaves (most specific frames) HOT 4
- support hot/cold flamegraphs HOT 1
- Document cargo features in readme HOT 1
- flamegraph does not contain sys_enter_* calls with params HOT 3
- Documentation, especially of folded format HOT 3
- publish packages HOT 5
- Error in generated SVG: PCDATA invalid Char value (macos) HOT 5
- Dependencies versions too loose HOT 1
- wallClockProfiler support
- graph diffs from perl flamegraph HOT 3
- Upgrade quick-xml
- Align FlameGraph color scheme to match original Perl script output 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 inferno.