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)
This commit is contained in:
Bart Hakvoort 2006-08-24 20:50:27 +00:00
parent 5631232ee1
commit 79c41f7be5
2 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2006-08-24 Bart Hakvoort <hakvoort@cvs.gnome.org>
* 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 <hakvoort@cvs.gnome.org>
* src/OperationDetail.cc: catch markup exceptions

View File

@ -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<Sector> 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 ) ) ;