Skip to content

Commit 9692f45

Browse files
authored
Merge pull request libgit2#7014 from libgit2/ethomson/index-bench
flamegraph: theme for libgit2 benchmarks site
2 parents 7daaf61 + f9e9ddd commit 9692f45

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

tests/benchmarks/_script/flamegraph/flamegraph.pl

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
my $inverted = 0; # icicle graph
121121
my $flamechart = 0; # produce a flame chart (sort by time, do not merge stacks)
122122
my $negate = 0; # switch differential hues
123-
my $titletext = ""; # centered heading
123+
my $titletext = "\000"; # centered heading
124124
my $titledefault = "Flame Graph"; # overwritten by --title
125125
my $titleinverted = "Icicle Graph"; # " "
126126
my $searchcolor = "rgb(230,0,230)"; # color for search highlighting
@@ -145,7 +145,8 @@ sub usage {
145145
# io, wakeup, chain, java, js, perl, red, green, blue,
146146
# aqua, yellow, purple, orange
147147
--bgcolors COLOR # set background colors. gradient choices are yellow
148-
# (default), blue, green, grey; flat colors use "#rrggbb"
148+
# (default), blue, green, grey; flat colors use "#rrggbb";
149+
# or none to omit a background
149150
--hash # colors are keyed by function name hash
150151
--random # colors are randomly generated
151152
--cp # use consistent palette (palette.map)
@@ -200,11 +201,11 @@ sub usage {
200201
my %Events;
201202
my %nameattr;
202203

203-
if ($flamechart && $titletext eq "") {
204+
if ($flamechart && $titletext eq "\000") {
204205
$titletext = "Flame Chart";
205206
}
206207

207-
if ($titletext eq "") {
208+
if ($titletext eq "\000") {
208209
unless ($inverted) {
209210
$titletext = $titledefault;
210211
} else {
@@ -267,7 +268,7 @@ sub usage {
267268
$bgcolor1 = "#f8f8f8"; $bgcolor2 = "#e8e8e8";
268269
} elsif ($bgcolors =~ /^#......$/) {
269270
$bgcolor1 = $bgcolor2 = $bgcolors;
270-
} else {
271+
} elsif ($bgcolors ne 'none') {
271272
die "Unrecognized bgcolor option \"$bgcolors\""
272273
}
273274

@@ -431,6 +432,12 @@ sub color {
431432
my $b = 190 + int(55 * $v2);
432433
return "rgb($r,$g,$b)";
433434
}
435+
if (defined $type and $type eq "libgit2") {
436+
my $alpha = sprintf("%.2f", 0.2 + (0.8 * (($v1 + $v2) / 2)));
437+
return ($v3 > 0.5) ?
438+
"rgba(241,80,47,$alpha)" :
439+
"rgba(55,125,205,$alpha)";
440+
}
434441

435442
# multi palettes
436443
if (defined $type and $type eq "java") {
@@ -777,13 +784,21 @@ sub flow {
777784
$im->colorAllocate(200, 200, 200),
778785
);
779786
$im->header($imagewidth, $imageheight);
780-
my $inc = <<INC;
787+
my $backgroundinc = '';
788+
789+
if ($bgcolors ne 'none') {
790+
$backgroundinc = <<INC;
781791
<defs>
782792
<linearGradient id="background" y1="0" y2="1" x1="0" x2="0" >
783793
<stop stop-color="$bgcolor1" offset="5%" />
784794
<stop stop-color="$bgcolor2" offset="95%" />
785795
</linearGradient>
786796
</defs>
797+
INC
798+
}
799+
800+
my $inc = <<INC;
801+
${backgroundinc}
787802
<style type="text/css">
788803
text { font-family:$fonttype; font-size:${fontsize}px; fill:$black; }
789804
#search, #ignorecase { opacity:0.1; cursor:pointer; }
@@ -1200,7 +1215,7 @@ sub flow {
12001215
INC
12011216
$im->include($inc);
12021217
$im->filledRectangle(0, 0, $imagewidth, $imageheight, 'url(#background)');
1203-
$im->stringTTF("title", int($imagewidth / 2), $fontsize * 2, $titletext);
1218+
$im->stringTTF("title", int($imagewidth / 2), $fontsize * 2, $titletext) if $titletext ne "";
12041219
$im->stringTTF("subtitle", int($imagewidth / 2), $fontsize * 4, $subtitletext) if $subtitletext ne "";
12051220
$im->stringTTF("details", $xpad, $imageheight - ($ypad2 / 2), " ");
12061221
$im->stringTTF("unzoom", $xpad, $fontsize * 2, "Reset Zoom", 'class="hide"');

tests/benchmarks/benchmark_helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ exec_profiler() {
438438
perf report --stdio --stdio-color "${COLOR_ARG}" -i "${SANDBOX_DIR}/perf.data"
439439
else
440440
perf script -i "${SANDBOX_DIR}/perf.data" | "${BENCHMARK_DIR}/_script/flamegraph/stackcollapse-perf.pl" > "${SANDBOX_DIR}/perf.data.folded"
441-
perl "${BENCHMARK_DIR}/_script/flamegraph/flamegraph.pl" "${SANDBOX_DIR}/perf.data.folded" > "${FLAMEGRAPH}"
441+
perl "${BENCHMARK_DIR}/_script/flamegraph/flamegraph.pl" -title "" -colors "libgit2" -bgcolors "none" "${SANDBOX_DIR}/perf.data.folded" > "${FLAMEGRAPH}"
442442
fi
443443
else
444444
# macos - requires system integrity protection is disabled :(

0 commit comments

Comments
 (0)