diff --git a/0001-minwidth-now-accepts-a-percentage-of-time-with-%.patch b/0001-minwidth-now-accepts-a-percentage-of-time-with-%.patch new file mode 100644 index 0000000..fe62735 --- /dev/null +++ b/0001-minwidth-now-accepts-a-percentage-of-time-with-%.patch @@ -0,0 +1,89 @@ +From b8989aab9a0815d44014f993127390200ecd23c7 Mon Sep 17 00:00:00 2001 +From: Ben Olson +Date: Tue, 17 Oct 2023 15:31:51 -0500 +Subject: [PATCH] minwidth now accepts a percentage of time with % + +--- + README.md | 3 ++- + flamegraph.pl | 26 ++++++++++++++++++++++---- + 2 files changed, 24 insertions(+), 5 deletions(-) + +diff --git a/README.md b/README.md +index 1aa3ecda..ee1b3eee 100644 +--- a/README.md ++++ b/README.md +@@ -167,7 +167,8 @@ USAGE: ./flamegraph.pl [options] infile > outfile.svg + --subtitle TEXT # second level title (optional) + --width NUM # width of image (default 1200) + --height NUM # height of each frame (default 16) +- --minwidth NUM # omit smaller functions (default 0.1 pixels) ++ --minwidth NUM # omit smaller functions. In pixels or use "%" for ++ # percentage of time (default 0.1 pixels) + --fonttype FONT # font type (default "Verdana") + --fontsize NUM # font size (default 12) + --countname TEXT # count type label (default "samples") +diff --git a/flamegraph.pl b/flamegraph.pl +index d2172b61..c5a7bc3d 100755 +--- a/flamegraph.pl ++++ b/flamegraph.pl +@@ -103,7 +103,7 @@ + my $frameheight = 16; # max height is dynamic + my $fontsize = 12; # base text size + my $fontwidth = 0.59; # avg width relative to fontsize +-my $minwidth = 0.1; # min function width, pixels ++my $minwidth = 0.1; # min function width, pixels or percentage of time + my $nametype = "Function:"; # what are the names in the data? + my $countname = "samples"; # what are the counts in the data? + my $colors = "hot"; # color theme +@@ -134,7 +134,8 @@ sub usage { + --subtitle TEXT # second level title (optional) + --width NUM # width of image (default 1200) + --height NUM # height of each frame (default 16) +- --minwidth NUM # omit smaller functions (default 0.1 pixels) ++ --minwidth NUM # omit smaller functions. In pixels or use "%" for ++ # percentage of time (default 0.1 pixels) + --fonttype FONT # font type (default "Verdana") + --fontsize NUM # font size (default 12) + --countname TEXT # count type label (default "samples") +@@ -165,7 +166,7 @@ sub usage { + 'encoding=s' => \$encoding, + 'fontsize=f' => \$fontsize, + 'fontwidth=f' => \$fontwidth, +- 'minwidth=f' => \$minwidth, ++ 'minwidth=s' => \$minwidth, + 'title=s' => \$titletext, + 'subtitle=s' => \$subtitletext, + 'nametype=s' => \$nametype, +@@ -224,6 +225,16 @@ sub usage { + die "Notes string can't contain < or >" + } + ++# Ensure minwidth is a valid floating-point number, ++# print usage string if not ++my $minwidth_f; ++if ($minwidth =~ /^([0-9.]+)%?$/) { ++ $minwidth_f = $1; ++} else { ++ warn "Value '$minwidth' is invalid for minwidth, expected a float.\n"; ++ usage(); ++} ++ + # background colors: + # - yellow gradient: default (hot, java, js, perl) + # - green gradient: mem +@@ -703,7 +714,14 @@ sub flow { + $timemax ||= $time; + + my $widthpertime = ($imagewidth - 2 * $xpad) / $timemax; +-my $minwidth_time = $minwidth / $widthpertime; ++ ++# Treat as a percentage of time if the string ends in a "%". ++my $minwidth_time; ++if ($minwidth =~ /%$/) { ++ $minwidth_time = $timemax * $minwidth_f / 100; ++} else { ++ $minwidth_time = $minwidth_f / $widthpertime; ++} + + # prune blocks that are too narrow and determine max depth + while (my ($id, $node) = each %Node) { diff --git a/flame.spec b/flame.spec index f2603e1..2e7d05f 100644 --- a/flame.spec +++ b/flame.spec @@ -7,10 +7,13 @@ Name: flamegraph Version: 1.0 Summary: Stack trace visualizer -Release: 1 +Release: 2 License: CDDL-1.0 URL: http://www.brendangregg.com/flamegraphs.html Source0: https://github.com/brendangregg/FlameGraph/FlameGraph-%{commit}.tar.gz + +Patch1: 0001-minwidth-now-accepts-a-percentage-of-time-with-%.patch + BuildArch: noarch BuildRequires: help2man BuildRequires: perl-generators @@ -151,5 +154,8 @@ cp -p *.1 %{buildroot}%{_mandir}/man1 %{_mandir}/man1/stackcollapse-xdebug.php.1* %changelog +* Fri Apr 18 2025 maxin - 1.0-2 +- minwidth now accepts a percentage of time with % + * Sat Aug 20 2022 zhujunhao - 1.0-1 - init package