aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/btl
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2010-02-26 14:57:49 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2010-02-26 14:57:49 +0100
commitac425090f389e34f9aee71b5957cca529ac74a38 (patch)
tree9fc044c93118431a53470ea9d1a6ba90a360e162 /bench/btl
parent8d4a0e6753117cbabf80e4b6fa13d3d3b6ba0327 (diff)
BTL: allow to bench real time
Diffstat (limited to 'bench/btl')
-rw-r--r--bench/btl/generic_bench/bench_parameter.hh2
-rw-r--r--bench/btl/generic_bench/btl.hh21
-rw-r--r--bench/btl/generic_bench/timers/portable_perf_analyzer.hh2
-rwxr-xr-xbench/btl/generic_bench/timers/portable_timer.hh44
4 files changed, 30 insertions, 39 deletions
diff --git a/bench/btl/generic_bench/bench_parameter.hh b/bench/btl/generic_bench/bench_parameter.hh
index d14340037..4c355cd6e 100644
--- a/bench/btl/generic_bench/bench_parameter.hh
+++ b/bench/btl/generic_bench/bench_parameter.hh
@@ -48,6 +48,6 @@
#define DEFAULT_NB_SAMPLE 1000
// how many times we run a single bench (keep the best perf)
-#define NB_TRIES 3
+#define DEFAULT_NB_TRIES 3
#endif
diff --git a/bench/btl/generic_bench/btl.hh b/bench/btl/generic_bench/btl.hh
index fdc099296..fd501c313 100644
--- a/bench/btl/generic_bench/btl.hh
+++ b/bench/btl/generic_bench/btl.hh
@@ -41,7 +41,7 @@
#if (defined __GNUC__)
#define BTL_ASM_COMMENT(X) asm("#"X)
#else
-#define BTL_ASM_COMMENT(X)
+#define BTL_ASM_COMMENT(X)
#endif
#if (defined __GNUC__) && (!defined __INTEL_COMPILER)
@@ -169,7 +169,7 @@ class BtlConfig
{
public:
BtlConfig()
- : overwriteResults(false), checkResults(true)
+ : overwriteResults(false), checkResults(true), realclock(false), tries(DEFAULT_NB_TRIES)
{
char * _config;
_config = getenv ("BTL_CONFIG");
@@ -189,6 +189,17 @@ public:
i += 1;
}
+ else if (config[i].beginsWith("-t"))
+ {
+ if (i+1==config.size())
+ {
+ std::cerr << "error processing option: " << config[i] << "\n";
+ exit(2);
+ }
+ Instance.tries = atoi(config[i+1].c_str());
+
+ i += 1;
+ }
else if (config[i].beginsWith("--overwrite"))
{
Instance.overwriteResults = true;
@@ -197,6 +208,10 @@ public:
{
Instance.checkResults = false;
}
+ else if (config[i].beginsWith("--real"))
+ {
+ Instance.realclock = true;
+ }
}
}
@@ -219,6 +234,8 @@ public:
static BtlConfig Instance;
bool overwriteResults;
bool checkResults;
+ bool realclock;
+ int tries;
protected:
std::vector<BtlString> m_selectedActionNames;
diff --git a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
index 6b1f8e7d7..5c337471e 100644
--- a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
+++ b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
@@ -53,7 +53,7 @@ public:
}
// optimize
- for (int i=1; i<NB_TRIES; ++i)
+ for (int i=1; i<BtlConfig::Instance.tries; ++i)
{
Action _action(size);
std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " ";
diff --git a/bench/btl/generic_bench/timers/portable_timer.hh b/bench/btl/generic_bench/timers/portable_timer.hh
index 42528d113..e6ad309fe 100755
--- a/bench/btl/generic_bench/timers/portable_timer.hh
+++ b/bench/btl/generic_bench/timers/portable_timer.hh
@@ -98,70 +98,44 @@ class Portable_Timer
{
public:
- Portable_Timer( void )
-// :_utime_sec_start(-1),
-// _utime_usec_start(-1),
-// _utime_sec_stop(-1),
-// _utime_usec_stop(-1)/*,
-// m_prev_cs(-1)*/
+ Portable_Timer()
{
+ m_clkid = BtlConfig::Instance.realclock ? CLOCK_REALTIME : CLOCK_PROCESS_CPUTIME_ID;
}
+ Portable_Timer(int clkid) : m_clkid(clkid)
+ {}
- void start()
+ void start()
{
-// int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
-// _utime_sec_start = resourcesUsage.ru_utime.tv_sec ;
-// _utime_usec_start = resourcesUsage.ru_utime.tv_usec ;
-
timespec ts;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
+ clock_gettime(m_clkid, &ts);
m_start_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
}
void stop()
{
-// int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
-// _utime_sec_stop = resourcesUsage.ru_utime.tv_sec ;
-// _utime_usec_stop = resourcesUsage.ru_utime.tv_usec ;
-
timespec ts;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
+ clock_gettime(m_clkid, &ts);
m_stop_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
}
double elapsed()
{
- return user_time();//double(_stop_time - _start_time) / CLOCKS_PER_SEC;
+ return user_time();
}
double user_time()
{
-// std::cout << m_prev_cs << "\n";
-// long tot_utime_sec=_utime_sec_stop-_utime_sec_start;
-// long tot_utime_usec=_utime_usec_stop-_utime_usec_start;
-// return double(tot_utime_sec)+ double(tot_utime_usec)/double(USEC_IN_SEC) ;
return m_stop_time - m_start_time;
}
private:
-// struct rusage resourcesUsage ;
-
-// long _utime_sec_start ;
-// long _utime_usec_start ;
-
-// long _utime_sec_stop ;
-// long _utime_usec_stop ;
-
-// long m_prev_cs;
-
-// std::clock_t _start_time;
-// std::clock_t _stop_time;
-
+ int m_clkid;
double m_stop_time, m_start_time;
}; // Portable_Timer