Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting real number for samples data #324

Open
Bojun-Seo opened this issue Nov 29, 2023 · 0 comments
Open

Supporting real number for samples data #324

Bojun-Seo opened this issue Nov 29, 2023 · 0 comments

Comments

@Bojun-Seo
Copy link

FlameGraph shows the number of samples in specific backtrace. Since it is the "number" of samples, it is an integer. But it can be expanded to real number. So I suggest to support real number for samples data. For example, think about the data like followings,

foo;bar;baz 0.156
foo;foo;bar;baz 0.98
foo;foo;foo;bar;baz 0.343
foo;foo;foo;foo;bar;baz 0.888

Every number of samples in flamegraph output svg file is 0 with the data.

I can see five decimal places of data if I change the code like followings.

$ git diff
diff --git a/flamegraph.pl b/flamegraph.pl
index 8c917ec..5855196 100755
--- a/flamegraph.pl
+++ b/flamegraph.pl
@@ -1233,7 +1233,7 @@ while (my ($id, $node) = each %Node) {

        # Add commas per perlfaq5:
        # https://perldoc.perl.org/perlfaq5#How-can-I-output-my-numbers-with-commas-added?
-       my $samples = sprintf "%.0f", ($etime - $stime) * $factor;
+       my $samples = sprintf "%.5f", ($etime - $stime) * $factor;
        (my $samples_txt = $samples)
                =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant