[Flake-enc-svnlog] SF.net SVN: flake-enc:[230] common.h
Status: Beta
Brought to you by:
jbr79
From: <jb...@us...> - 2008-08-09 13:37:47
|
Revision: 230 http://flake-enc.svn.sourceforge.net/flake-enc/?rev=230&view=rev Author: jbr79 Date: 2008-08-09 13:37:57 +0000 (Sat, 09 Aug 2008) Log Message: ----------- add a timer to use in benchmarks Modified Paths: -------------- common.h Modified: common.h =================================================================== --- common.h 2008-08-09 13:33:45 UTC (rev 229) +++ common.h 2008-08-09 13:37:57 UTC (rev 230) @@ -2,6 +2,9 @@ * Flake: FLAC audio encoder * Copyright (c) 2006-2007 Justin Ruggles * + * STOP/START_TIMER is from FFmpeg libavutil/common.h + * Copyright (c) 2006 Michael Niedermayer <mic...@gm...> + * * Flake is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -76,4 +79,36 @@ extern size_t strnlen(const char *s, size_t maxlen); #endif + +#if 0 /* TIMER USED FOR TESTING */ +static inline long long read_time(void) +{ + long long l; + __asm__ __volatile__("rdtsc\n\t" + : "=A" (l)); + return l; +} + +#define START_TIMER \ +uint64_t tend;\ +uint64_t tstart = read_time();\ + +#define STOP_TIMER(id) \ +tend= read_time();\ +{\ + static uint64_t tsum=0;\ + static int tcount=0;\ + static int tskip_count=0;\ + if(tcount<2 || tend - tstart < MAX(8*tsum/tcount, 2000)){\ + tsum+= tend - tstart;\ + tcount++;\ + }else\ + tskip_count++;\ + if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\ + fprintf(stderr, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\ + tsum*10/tcount, id, tcount, tskip_count);\ + }\ +} +#endif + #endif /* COMMON_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |