summaryrefslogtreecommitdiff
path: root/liboil/liboilprofile.c
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2004-12-03 06:53:29 +0000
committerDavid Schleef <ds@schleef.org>2004-12-03 06:53:29 +0000
commitce07c4fc40170e387484efb63d45bff54713c97d (patch)
tree01302a17cedcf6a22999099ba071464f8509f72b /liboil/liboilprofile.c
parente02bccc7ad6eeb1ac6eb6691b3e63cbc1786ec1c (diff)
downloadliboil-ce07c4fc40170e387484efb63d45bff54713c97d.tar.gz
* liboil/Makefile.am: add null.c, libprofile.c
* liboil/null.c: a null function * liboil/liboilprofile.c: profiling code * liboil/conv_3dnow.c: (conv_f32_s32_3dnow), (conv_s32_f32_3dnow): add 'emms' * liboil/liboilprofile.h: clean up, move some stuff to .c * liboil/liboiltest.c: (oil_test_go): fix for profile changes * liboil/simdpack/abs_u16_s16.c: (abs_u16_s16_mmx), (abs_u16_s16_mmxx), (abs_u16_s16_mmx2): add 'emms' * testsuite/md5_profile.c: (test): fix for profile changes * testsuite/test1.c: (main), (calc_average), (calc_std), (calc_std2), (calc_max), (hist): fix for profile changes. Add code to get a good estimate of the average execution time, removing outliers.
Diffstat (limited to 'liboil/liboilprofile.c')
-rw-r--r--liboil/liboilprofile.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/liboil/liboilprofile.c b/liboil/liboilprofile.c
new file mode 100644
index 0000000..07f0dfa
--- /dev/null
+++ b/liboil/liboilprofile.c
@@ -0,0 +1,72 @@
+/* liboil - Library of Optimized Inner Loops
+ * Copyright (C) 2003 David A. Schleef <ds@schleef.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2.1 of the GNU Lesser General
+ * Public License as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <liboil/liboilprofile.h>
+
+#include <sys/time.h>
+#include <time.h>
+#include <string.h>
+
+#ifdef OIL_PROFILE_USING_GTOD
+unsigned long oil_profile_stamp_gtod (void)
+{
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ return 1000000*(unsigned long)tv.tv_sec + (unsigned long)tv.tv_usec;
+}
+
+#endif
+
+void
+oil_profile_init (OilProfile *prof)
+{
+ memset(prof, 0, sizeof(OilProfile));
+
+ prof->min = -1;
+
+}
+
+void
+oil_profile_stop_handle (OilProfile *prof)
+{
+ int i;
+
+ prof->last = prof->stop - prof->start;
+
+ prof->total += prof->last;
+ prof->n++;
+
+ if (prof->last < prof->min) prof->min = prof->last;
+
+ for(i=0;i<prof->hist_n;i++) {
+ if (prof->last == prof->hist_time[i]) {
+ prof->hist_count[i]++;
+ break;
+ }
+ }
+ if (i == prof->hist_n && prof->hist_n < OIL_PROFILE_HIST_LENGTH) {
+ prof->hist_time[prof->hist_n] = prof->last;
+ prof->hist_count[prof->hist_n] = 1;
+ prof->hist_n++;
+ }
+}
+