diff --git a/rotation.cpp b/rotation.cpp index 6a81a0a..f17cce6 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -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(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(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(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; }