Commit 02f4ee114ca2669a5e894702ba666ea7f0057b03

Steffen Jaeckel 2019-10-28T15:23:34

compare logs before and after single-object profiling

diff --git a/logs/Makefile b/logs/Makefile
index c2ebaf7..59987e5 100644
--- a/logs/Makefile
+++ b/logs/Makefile
@@ -1,2 +1,9 @@
 all:
-	gnuplot graphs.dem
+	sed -e 's@\.log@-$(VERSION)\.log@g' graphs.dem > graphs-$(VERSION).dem
+	gnuplot graphs-$(VERSION).dem
+
+cmp:
+	gnuplot before_after.dem
+
+clean:
+	rm -f *-*.log *.png graphs-*.dem
diff --git a/logs/before_after.dem b/logs/before_after.dem
new file mode 100644
index 0000000..edb59da
--- /dev/null
+++ b/logs/before_after.dem
@@ -0,0 +1,36 @@
+set terminal png
+set ylabel "Cycles per Operation"
+set xlabel "Operand size (bits)"
+
+set output "addsub-ba.png"
+plot 'add-before.log' smooth bezier title "Addition (before)", \
+      'add-after.log' smooth bezier title "Addition (after)", \
+      'sub-before.log' smooth bezier title "Subtraction (before)", \
+      'sub-after.log' smooth bezier title "Subtraction (after)"
+
+set output "mult-ba.png"
+plot 'mult-before.log' smooth bezier title "Multiplication (without Karatsuba) (before)", \
+      'mult-after.log' smooth bezier title "Multiplication (without Karatsuba) (after)", \
+      'mult_kara-before.log' smooth bezier title "Multiplication (Karatsuba) (before)", \
+      'mult_kara-after.log' smooth bezier title "Multiplication (Karatsuba) (after)"
+
+set output "sqr-ba.png"
+plot 'sqr-before.log' smooth bezier title "Squaring (without Karatsuba) (before)", \
+      'sqr-after.log' smooth bezier title "Squaring (without Karatsuba) (after)", \
+      'sqr_kara-before.log' smooth bezier title "Squaring (Karatsuba) (before)", \
+      'sqr_kara-after.log' smooth bezier title "Squaring (Karatsuba) (after)"
+
+set output "expt-ba.png"
+plot 'expt-before.log' smooth bezier title "Exptmod (Montgomery) (before)", \
+      'expt-after.log' smooth bezier title "Exptmod (Montgomery) (after)", \
+      'expt_dr-before.log' smooth bezier title "Exptmod (Dimminished Radix) (before)", \
+      'expt_dr-after.log' smooth bezier title "Exptmod (Dimminished Radix) (after)", \
+      'expt_2k-before.log' smooth bezier title "Exptmod (2k Reduction) (before)", \
+      'expt_2k-after.log' smooth bezier title "Exptmod (2k Reduction) (after)", \
+      'expt_2kl-before.log' smooth bezier title "Exptmod (2k-l Reduction) (before)", \
+      'expt_2kl-after.log' smooth bezier title "Exptmod (2k-l Reduction) (after)"
+
+set output "invmod-ba.png"
+plot 'invmod-before.log' smooth bezier title "Modular Inverse (before)", \
+      'invmod-after.log' smooth bezier title "Modular Inverse (after)"
+
diff --git a/logs/before_after.html b/logs/before_after.html
new file mode 100644
index 0000000..bc866f2
--- /dev/null
+++ b/logs/before_after.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title>LibTomMath Log Plots</title>
+</head>
+<body>
+
+<h1>Addition and Subtraction</h1>
+<center><img src=addsub-ba.png></center>
+<hr>
+
+<h1>Multiplication</h1>
+<center><img src=mult-ba.png></center>
+<hr>
+
+<h1>Squaring</h1>
+<center><img src=sqr-ba.png></center>
+<hr>
+
+<h1>Exptmod</h1>
+<center><img src=expt-ba.png></center>
+<hr>
+
+<h1>Modular Inverse</h1>
+<center><img src=invmod-ba.png></center>
+<hr>
+
+</body>
+</html>
diff --git a/logs/index.html b/logs/index.html
index 4b68c25..8c1ed9d 100644
--- a/logs/index.html
+++ b/logs/index.html
@@ -22,6 +22,3 @@
 
 </body>
 </html>
-/* $Source: /cvs/libtom/libtommath/logs/index.html,v $ */
-/* $Revision: 1.2 $ */
-/* $Date: 2005/05/05 14:38:47 $ */
diff --git a/makefile b/makefile
index 8dd22ef..9a2b361 100644
--- a/makefile
+++ b/makefile
@@ -72,7 +72,7 @@ profiled:
 #make a single object profiled library
 profiled_single: pre_gen
 	$(CC) $(LTM_CFLAGS) -fprofile-arcs -c pre_gen/mp_all.c -o mp_all.o
-	$(CC) $(LTM_CFLAGS) demo/timing.c mp_all.o -lgcov -o timing
+	$(CC) $(LTM_CFLAGS) -DMP_VERSION=\"before\" demo/timing.c mp_all.o -lgcov -o timing
 	./timing
 	rm -f *.o timing
 	$(CC) $(LTM_CFLAGS) -fbranch-probabilities -c pre_gen/mp_all.c -o mp_all.o
@@ -117,13 +117,18 @@ coveralls: lcov
 docs manual:
 	$(MAKE) -C doc/ $@ V=$(V)
 
-.PHONY: pre_gen
+.PHONY: pre_gen cmp
 pre_gen:
 	mkdir -p pre_gen
 	cat *mp_*.c > mp_all.c
 	sed -e 's/[[:blank:]]*$$//' mp_all.c > pre_gen/mp_all.c
 	rm mp_all.c
 
+cmp: profiled_single
+	$(CC) $(LTM_CFLAGS) -DMP_VERSION=\"after\" demo/timing.c $(LIBNAME) -lgcov -o timing
+	./timing
+	$(MAKE) -C logs/ cmp
+
 zipup: clean astyle new_file docs
 	@# Update the index, so diff-index won't fail in case the pdf has been created.
 	@#   As the pdf creation modifies the tex files, git sometimes detects the