gparted r880 - in trunk: . src
- From: gedakc svn gnome org
- To: svn-commits-list gnome org
- Subject: gparted r880 - in trunk: . src
- Date: Thu, 7 Aug 2008 02:06:00 +0000 (UTC)
Author: gedakc
Date: Thu Aug 7 02:06:00 2008
New Revision: 880
URL: http://svn.gnome.org/viewvc/gparted?rev=880&view=rev
Log:
Enhanced optimal block size copy algorithm to reduce time required to move or copy partitions
Modified:
trunk/ChangeLog
trunk/src/GParted_Core.cc
Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc (original)
+++ trunk/src/GParted_Core.cc Thu Aug 7 02:06:00 2008
@@ -1723,7 +1723,8 @@
operationdetail .add_child( OperationDetail( _("finding optimal blocksize"), STATUS_NONE ) ) ;
- Sector optimal_blocksize = readonly ? 128 : 64, N = 32768 ;
+ Sector benchmark_blocksize = readonly ? 128 : 64, N = 65536 ;
+ Sector optimal_blocksize = benchmark_blocksize ;
Sector offset_read = src_start,
offset_write = dst_start ;
@@ -1739,24 +1740,18 @@
double smallest_time = 1000000 ;
bool succes = true ;
+ //Benchmark copy times using different block sizes to determine optimal size
while ( succes &&
- timer .elapsed() <= smallest_time &&
std::llabs( done ) + N <= length &&
- optimal_blocksize * 2 < N )
+ benchmark_blocksize <= N )
{
- if ( done != 0 )
- {
- smallest_time = timer .elapsed() ;
- optimal_blocksize *= 2 ;
- }
-
timer .reset() ;
succes = copy_blocks( src_device,
dst_device,
offset_read + done,
offset_write + done,
N,
- optimal_blocksize,
+ benchmark_blocksize,
operationdetail .get_last_child(),
readonly,
total_done ) ;
@@ -1764,16 +1759,20 @@
operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail(
String::ucompose( _("%1 seconds"), timer .elapsed() ), STATUS_NONE, FONT_ITALIC ) ) ;
-
+
+ if ( timer .elapsed() <= smallest_time )
+ {
+ smallest_time = timer .elapsed() ;
+ optimal_blocksize = benchmark_blocksize ;
+ }
+ benchmark_blocksize *= 2 ;
+
if ( ( dst_start > src_start ) )
done -= N ;
else
done += N ;
}
- if ( timer .elapsed() > smallest_time )
- optimal_blocksize /= 2 ;
-
if ( succes )
operationdetail .get_last_child() .add_child( OperationDetail( String::ucompose( _("optimal blocksize is %1 sectors (%2)"),
optimal_blocksize,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]