[RFT PATCH -perfbook 2/2] CodeSamples/cpu/data: Use "smooth frequency" for plotting histogram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add gnuplot scripts for generating EPS plots.

Use "smooth frequency" feature of gnuplot for plotting distribution
histograms.

Distribution data in coe.dat, fre.dat, and rfe.dat are converted
on-the-fly into single-column data by using expand.pl as a filter.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 .../expand.pl                                 | 42 ++++++++++
 .../plots.sh                                  | 83 +++++++++++++++++++
 2 files changed, 125 insertions(+)
 create mode 100755 CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/expand.pl

diff --git a/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/expand.pl b/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/expand.pl
new file mode 100755
index 00000000..30719692
--- /dev/null
+++ b/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/expand.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Expand frequency data of the form:
+#
+#   1000 4
+#   1004 2
+#   1050 1
+#
+# into:
+#
+#   1000
+#   1000
+#   1000
+#   1000
+#   1004
+#   1004
+#   1050
+#
+# Copyright (C) Akira Yokosawa, 2024
+#
+# Authors: Akira Yokosawa <akiyks@xxxxxxxxx>
+
+use strict;
+use warnings;
+
+my $line;
+my $freq;
+my $count;
+
+open(my $fn, '<:encoding(UTF-8)', $ARGV[0])
+    or die "Could not open file '$ARGV[0]' $!";
+
+while($line = <$fn>) {
+    if ($line =~ /(\-?[0-9]+)\s+([0-9]+)/ ) {
+	$freq = $1;
+	$count = $2;
+	for (my $i = 0; $i < $count; $i++) {
+	    print "$freq\n";
+	}
+    }
+}
diff --git a/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/plots.sh b/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/plots.sh
index 5b589858..ca083bca 100644
--- a/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/plots.sh
+++ b/CodeSamples/cpu/data/kerneltest009.05.atn6.2024.01.17-08.25.02/plots.sh
@@ -67,3 +67,86 @@ set nokey
 # set label 5 "refcnt" at 0.15,2.8 left
 plot "rfe.dat" w points pt 6 pointsize 0.5
 ---EOF---
+
+# For eps output
+font=../../../../fonts/uhvr8a.pfb
+fontsize=8
+przsize="nosquare 0.55,0.25"
+
+gnuplot << ---EOF---
+set term postscript portrait color ${fontsize} enhanced fontfile "${font}" "NimbusSanL-Regu" 
+set size $przsize
+set output "coe-nvals.eps"
+
+set xlabel "Time (Timestamp Periods)"
+set ylabel "Number of Simultaneous Values"
+#set logscale y
+set xrange [:10000]
+#set yrange [100:10000]
+set nokey
+plot "coe-nvals.dat" w l
+---EOF---
+
+gnuplot << ---EOF---
+set term postscript portrait color ${fontsize} enhanced fontfile "${font}" "NimbusSanL-Regu"
+set size $przsize
+set output "coe.eps"
+stats "< perl expand.pl coe.dat" nooutput
+N = STATS_records
+
+set xlabel "Store-to-Store Latency (Timestamp Periods)"
+set ylabel "Frequency (arb. unit)"
+#set logscale y
+set xrange [-1000:3000]
+set yrange [0:]
+set nokey
+#set border 3
+set yzeroaxis
+set boxwidth 40
+#set style fill solid 1.0 noborder
+bin_width = 40
+bin(x) = bin_width * floor(x/bin_width)
+plot "< perl expand.pl coe.dat" using (bin(column(1))):(20./N) smooth frequency with boxes
+---EOF---
+
+gnuplot << ---EOF---
+set term postscript portrait color ${fontsize} enhanced fontfile "${font}" "NimbusSanL-Regu"
+set size $przsize
+set output "fre.eps"
+stats "< perl expand.pl fre.dat" nooutput
+N = STATS_records
+
+set xlabel "Load-to-Store Latency (Timestamp Periods)"
+set ylabel "Frequency (arb. unit)"
+#set logscale y
+set xrange [-250:50]
+set yrange [0:]
+set nokey
+set yzeroaxis
+set boxwidth 2
+#set style fill solid 1.0 noborder
+bin_width = 2
+bin(x) = bin_width * floor(x/bin_width)
+plot "< perl expand.pl fre.dat" using (bin(column(1))):(20./N) smooth frequency with boxes
+---EOF---
+
+gnuplot << ---EOF---
+set term postscript portrait color ${fontsize} enhanced fontfile "${font}" "NimbusSanL-Regu"
+set size $przsize
+set output "rfe.eps"
+stats "< perl expand.pl rfe.dat" nooutput
+N = STATS_records
+
+set xlabel "Store-to-Load Latency (Timestamp Periods)"
+set ylabel "Frequency (arb. unit)"
+#set logscale y
+set xrange [0:350]
+set yrange [0:]
+set nokey
+set yzeroaxis
+set boxwidth 2
+#set style fill solid 1.0 noborder
+bin_width = 2
+bin(x) = bin_width * floor(x/bin_width)
+plot "< perl expand.pl rfe.dat" using (bin(column(1))):(20./N) smooth frequency with boxes
+---EOF---
-- 
2.34.1






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux