Tweak stats display.
Add average metric.
This commit is contained in:
parent
68fb1b1951
commit
54e35ff8d0
40
rotation.cpp
40
rotation.cpp
|
@ -1,6 +1,7 @@
|
|||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
|
@ -1024,30 +1025,45 @@ int main(int argc, char* argv[])
|
|||
Image img(argv[1]);
|
||||
TiledImage<8, 8> tiled_img(argv[1]);
|
||||
|
||||
// No tile
|
||||
float average = 0.0;
|
||||
int i = 0;
|
||||
for (double rotation = 0; rotation < 360; rotation += 45)
|
||||
{
|
||||
// No tile
|
||||
auto const before = chrono::high_resolution_clock::now();
|
||||
Image* const rotated = rotate(img, rotation);
|
||||
auto const after = chrono::high_resolution_clock::now();
|
||||
auto const duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(after - before);
|
||||
|
||||
// Tile
|
||||
auto const before_tiled = chrono::high_resolution_clock::now();
|
||||
auto const rotated_tiled = rotate(tiled_img, rotation);
|
||||
auto const after_tiled = chrono::high_resolution_clock::now();
|
||||
auto const duration_ms_tiled = std::chrono::duration_cast<std::chrono::milliseconds>(after_tiled - before_tiled);
|
||||
average += duration_ms.count();
|
||||
|
||||
cout << "rotate(" << rotation << "): " << duration_ms.count() << " ms" << endl;
|
||||
cout << "tiled: " << duration_ms_tiled.count() << " ms" << endl;
|
||||
cout << "speedup: " << (int) (((float) duration_ms.count() / duration_ms_tiled.count() - 1) * 100) << "%" << endl << endl;
|
||||
|
||||
rotated->save(get_save_path("rotated", rotation));
|
||||
rotated_tiled->save(get_save_path("rotated_tiled", rotation));
|
||||
|
||||
delete rotated;
|
||||
delete rotated_tiled;
|
||||
++i;
|
||||
}
|
||||
cout << "---------" << endl;
|
||||
cout << " average: " << average / i << "ms" << endl << endl;
|
||||
|
||||
// Tile
|
||||
average = 0.0;
|
||||
i = 0;
|
||||
for (double rotation = 0; rotation < 360; rotation += 45)
|
||||
{
|
||||
auto const before = chrono::high_resolution_clock::now();
|
||||
auto const rotated = rotate(tiled_img, rotation);
|
||||
auto const after = chrono::high_resolution_clock::now();
|
||||
auto const duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(after - before);
|
||||
average += duration_ms.count();
|
||||
|
||||
cout << "rotate tiled(" << rotation << "): " << duration_ms.count() << " ms" << endl;
|
||||
|
||||
rotated->save(get_save_path("rotated_tiled", rotation));
|
||||
delete rotated;
|
||||
++i;
|
||||
}
|
||||
cout << "---------" << endl;
|
||||
cout << " average: " << average / i << "ms" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue