aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/btl/generic_bench/timers
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-07-27 11:39:47 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-07-27 11:39:47 +0000
commit93115619c23bb41fd24b0090cb6adec501edaced (patch)
tree60ae0887b0705b8a994f8ef9baa5324c87883861 /bench/btl/generic_bench/timers
parente9e5261664cc77049f8b77a2c36c535fbd44889c (diff)
* updated benchmark files according to recent renamings
* various improvements in BTL including trisolver and cholesky bench
Diffstat (limited to 'bench/btl/generic_bench/timers')
-rw-r--r--bench/btl/generic_bench/timers/portable_perf_analyzer.hh16
-rwxr-xr-xbench/btl/generic_bench/timers/portable_timer.hh54
2 files changed, 53 insertions, 17 deletions
diff --git a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
index d716154fd..d0fe95ce0 100644
--- a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
+++ b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
@@ -38,16 +38,16 @@ public:
MESSAGE("Portable_Perf_Analyzer Dtor");
};
-
-
BTL_DONT_INLINE double eval_mflops(int size)
{
Action action(size);
-
- double time_action = time_calculate(action);
+ double time_action = 0;
+ action.initialize();
+ time_action = time_calculate(action);
while (time_action < MIN_TIME)
{
+ //Action action(size);
_nb_calc *= 2;
action.initialize();
time_action = time_calculate(action);
@@ -56,8 +56,10 @@ public:
// optimize
for (int i=1; i<NB_TRIES; ++i)
{
- action.initialize();
- time_action = std::min(time_action, time_calculate(action));
+ Action _action(size);
+ std::cout << " " << _action.nb_op_base()*_nb_calc/(time_action*1e6) << " ";
+ _action.initialize();
+ time_action = std::min(time_action, time_calculate(_action));
}
time_action = time_action / (double(_nb_calc));
@@ -66,13 +68,13 @@ public:
action.initialize();
action.calculate();
action.check_result();
-
return action.nb_op_base()/(time_action*1000000.0);
}
BTL_DONT_INLINE double time_calculate(Action & action)
{
// time measurement
+ action.calculate();
_chronos.start();
for (int ii=0;ii<_nb_calc;ii++)
{
diff --git a/bench/btl/generic_bench/timers/portable_timer.hh b/bench/btl/generic_bench/timers/portable_timer.hh
index 7d4059464..de50394f9 100755
--- a/bench/btl/generic_bench/timers/portable_timer.hh
+++ b/bench/btl/generic_bench/timers/portable_timer.hh
@@ -39,6 +39,38 @@
// A timer object measures CPU time.
+// class Portable_Timer
+// {
+// public:
+//
+// Portable_Timer( void )
+// {
+// }
+//
+//
+// void start() { m_val = getTime(); }
+//
+// void stop() { m_val = getTime() - m_val; }
+//
+// double elapsed() { return m_val; }
+//
+// double user_time() { return elapsed(); }
+//
+//
+// private:
+//
+// static inline double getTime(void)
+// {
+// struct timeval tv;
+// struct timezone tz;
+// gettimeofday(&tv, &tz);
+// return (double)tv.tv_sec + 1.e-6 * (double)tv.tv_usec;
+// }
+//
+// double m_val;
+//
+// }; // Portable_Timer
+
class Portable_Timer
{
public:
@@ -46,42 +78,42 @@ class Portable_Timer
Portable_Timer( void ):_utime_sec_start(-1),
_utime_usec_start(-1),
_utime_sec_stop(-1),
- _utime_usec_stop(-1)
+ _utime_usec_stop(-1)/*,
+ m_prev_cs(-1)*/
{
}
void start()
{
-
int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
-
- _start_time = std::clock();
-
+// _start_time = std::clock();
_utime_sec_start = resourcesUsage.ru_utime.tv_sec ;
_utime_usec_start = resourcesUsage.ru_utime.tv_usec ;
+// m_prev_cs = resourcesUsage.ru_nivcsw;
}
void stop()
{
-
int status=getrusage(RUSAGE_SELF, &resourcesUsage) ;
-
- _stop_time = std::clock();
-
+// _stop_time = std::clock();
_utime_sec_stop = resourcesUsage.ru_utime.tv_sec ;
_utime_usec_stop = resourcesUsage.ru_utime.tv_usec ;
+// m_prev_cs = resourcesUsage.ru_nivcsw - m_prev_cs;
+// std::cerr << resourcesUsage.ru_nvcsw << " + " << resourcesUsage.ru_nivcsw << "\n";
+
}
double elapsed()
{
- return double(_stop_time - _start_time) / CLOCKS_PER_SEC;
+ return user_time();//double(_stop_time - _start_time) / CLOCKS_PER_SEC;
}
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) ;
@@ -98,6 +130,8 @@ private:
long _utime_sec_stop ;
long _utime_usec_stop ;
+// long m_prev_cs;
+
std::clock_t _start_time;
std::clock_t _stop_time;