mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-23 15:23:49 +00:00
Use the flag to perform 'n' computations and average the total time taken.
This commit is contained in:
parent
7116cc8b89
commit
8bea381389
1 changed files with 27 additions and 8 deletions
|
@ -91,7 +91,6 @@ CompressedImage * CompressImage(
|
||||||
CompressionFunc f = ChooseFuncFromSettings(settings);
|
CompressionFunc f = ChooseFuncFromSettings(settings);
|
||||||
if(f) {
|
if(f) {
|
||||||
|
|
||||||
StopWatch stopWatch = StopWatch();
|
|
||||||
double cmpMSTime = 0.0;
|
double cmpMSTime = 0.0;
|
||||||
|
|
||||||
if(settings.iNumThreads > 1) {
|
if(settings.iNumThreads > 1) {
|
||||||
|
@ -102,22 +101,42 @@ CompressedImage * CompressImage(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tgrp.Start();
|
double cmpTimeTotal = 0.0;
|
||||||
tgrp.Join();
|
for(int i = 0; i < settings.iNumCompressions; i++) {
|
||||||
|
if(i > 0)
|
||||||
|
tgrp.PrepareThreads();
|
||||||
|
|
||||||
stopWatch = tgrp.GetStopWatch();
|
tgrp.Start();
|
||||||
|
tgrp.Join();
|
||||||
|
|
||||||
|
StopWatch stopWatch = tgrp.GetStopWatch();
|
||||||
|
cmpTimeTotal += tgrp.GetStopWatch().TimeInMilliseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
cmpMSTime = cmpTimeTotal / double(settings.iNumCompressions);
|
||||||
|
|
||||||
tgrp.CleanUpThreads();
|
tgrp.CleanUpThreads();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stopWatch.Start();
|
double cmpTimeTotal = 0.0;
|
||||||
(*f)(img.GetPixels(), cmpData, img.GetWidth(), img.GetHeight());
|
for(int i = 0; i < settings.iNumCompressions; i++) {
|
||||||
stopWatch.Stop();
|
|
||||||
|
StopWatch stopWatch = StopWatch();
|
||||||
|
stopWatch.Reset();
|
||||||
|
stopWatch.Start();
|
||||||
|
|
||||||
|
(*f)(img.GetPixels(), cmpData, img.GetWidth(), img.GetHeight());
|
||||||
|
stopWatch.Stop();
|
||||||
|
|
||||||
|
cmpTimeTotal += stopWatch.TimeInMilliseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
cmpMSTime = cmpTimeTotal / double(settings.iNumCompressions);
|
||||||
outImg = new CompressedImage(img.GetWidth(), img.GetHeight(), settings.format, cmpData);
|
outImg = new CompressedImage(img.GetWidth(), img.GetHeight(), settings.format, cmpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report compression time
|
// Report compression time
|
||||||
fprintf(stdout, "Compression time: %0.3f ms\n", stopWatch.TimeInMilliseconds());
|
fprintf(stdout, "Compression time: %0.3f ms\n", cmpMSTime);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ReportError("Could not find adequate compression function for specified settings");
|
ReportError("Could not find adequate compression function for specified settings");
|
||||||
|
|
Loading…
Reference in a new issue