From 79c41f7be590c95923600fa3c29d8e56c915c27d Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Thu, 24 Aug 2006 20:50:27 +0000 Subject: [PATCH] use Glib::timer instead of std::time stuff for the probing, this is more * src/GParted_Core.cc: use Glib::timer instead of std::time stuff for the probing, this is more accurate since the resolution is much higher (microseconds instead of seconds) --- ChangeLog | 6 ++++++ src/GParted_Core.cc | 15 +++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 620261c9..38bf86fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-08-24 Bart Hakvoort + + * src/GParted_Core.cc: use Glib::timer instead of std::time stuff for + the probing, this is more accurate since the resolution is much + higher (microseconds instead of seconds) + 2006-08-24 Bart Hakvoort * src/OperationDetail.cc: catch markup exceptions diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index af86ac37..73d8589f 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -1664,7 +1664,8 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old, { operationdetail .add_child( OperationDetail( _("finding optimal blocksize"), STATUS_NONE ) ) ; - std::clock_t clockticks_start, smallest_ticks = -1 ; + Glib::Timer timer ; + double smallest_time = -1 ; std::vector blocksizes ; blocksizes .push_back( 1 ) ; @@ -1675,7 +1676,8 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old, for ( unsigned int t = 0 ; t < blocksizes .size() && succes ; t++ ) { - clockticks_start = std::clock() ; + timer .reset() ; + timer .start() ; succes = copy_blocks( partition_old .device_path, partition_new .device_path, @@ -1685,15 +1687,16 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old, 20000, operationdetail .get_last_child(), copytype ) ; - - if ( (std::clock() - clockticks_start) < smallest_ticks || smallest_ticks == -1 ) + timer .stop() ; + + if ( timer .elapsed() < smallest_time || smallest_time == -1 ) { - smallest_ticks = std::clock() - clockticks_start ; + smallest_time = timer .elapsed() ; optimal_blocksize = blocksizes[ t ] ; } operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail( - String::ucompose( _("%1 clockticks"), std::clock() - clockticks_start ), + String::ucompose( _("%1 seconds"), timer .elapsed() ), STATUS_NONE, FONT_ITALIC ) ) ;