← easystroke

Print the number of us it took to create the matrix

f8913175942d51373324f28f2a58da86fc649b44 · Thomas Jaeger · Jan 16, 2010 00:17

+7 −31 · 3 files changed

  • stats.cc +7 −3
  • util.cc +0 −26
  • util.h +0 −2
diff --git a/stats.cc b/stats.cc
index de5e3a3..c4f9d51 100644
--- a/stats.cc
+++ b/stats.cc
@@ -18,6 +18,7 @@
 #include "main.h"
 #include <iomanip>
 #include <glibmm/i18n.h>
+#include <sys/time.h>
 
 Stats::Stats() {
 	Gtk::Button *button_matrix;
@@ -205,8 +206,9 @@ bool Stats::on_stroke(RRanking r) {
 }
 
 void Stats::on_pdf() {
+	struct timeval tv1, tv2;
 	if (verbosity >= 1)
-		show_us("Creating table: ");
+		gettimeofday(&tv1, 0);
 	const int S = 32;
 	const int B = 1;
 	std::list<RStroke> strokes;
@@ -247,8 +249,10 @@ void Stats::on_pdf() {
 			ctx->show_text(str);
 		}
 	}
-	if (verbosity >= 1)
-		show_us("Table completed: ");
+	if (verbosity >= 1) {
+		gettimeofday(&tv2, 0);
+		printf("creating table took %ld us\n", (tv2.tv_sec - tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec);
+	}
 	if (!fork()) {
 		execlp("xdg-open", "xdg-open", "/tmp/strokes.pdf", NULL);
 		exit(EXIT_FAILURE);
diff --git a/util.cc b/util.cc
deleted file mode 100644
index ff3cabd..0000000
--- a/util.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2008, Thomas Jaeger <ThJaeger@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#include "util.h"
-
-#include <stdio.h>
-#include <sys/time.h>
-#include <time.h>
-
-void show_us(const char *str) {
-	struct timeval tv;
-	gettimeofday(&tv, 0);
-	printf("%s: %ld.%ld\n", str, tv.tv_sec, tv.tv_usec);
-}
diff --git a/util.h b/util.h
index 6ff8910..97dde2c 100644
--- a/util.h
+++ b/util.h
@@ -46,6 +46,4 @@ public:
 		remove_timeout();
 	}
 };
-
-void show_us(const char *str);
 #endif