Print the number of us it took to create the matrix
+7 −31 · 3 files changed
-
stats.cc+7 −3 -
util.cc+0 −26 -
util.h+0 −2
@@ -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); @@ -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); -} @@ -46,6 +46,4 @@ public: remove_timeout(); } }; - -void show_us(const char *str); #endif