diff --git a/src/app/editor_benchmark.cpp b/src/app/editor_benchmark.cpp index 396865408..f82db2475 100644 --- a/src/app/editor_benchmark.cpp +++ b/src/app/editor_benchmark.cpp @@ -43,7 +43,7 @@ void BM_ScrollEditor(benchmark::State& state) { auto mgr = ui::Manager::getDefault(); mgr->dontWaitEvents(); - while (state.KeepRunning()) { + for (auto _ : state) { editor->setEditorScroll(gfx::Point(0, 0)); mgr->generateMessages(); mgr->dispatchMessages(); @@ -70,7 +70,7 @@ void BM_ZoomEditor(benchmark::State& state) { auto mgr = ui::Manager::getDefault(); mgr->dontWaitEvents(); - while (state.KeepRunning()) { + for (auto _ : state) { editor->setZoom(render::Zoom(4, 1)); editor->invalidate(); mgr->generateMessages(); @@ -140,9 +140,10 @@ int app_main(int argc, char* argv[]) app.initialize(AppOptions(1, { argv2 })); app.mainWindow()->expandWindow(gfx::Size(400, 300)); - ::benchmark::Initialize(&argc, argv); - int status = ::benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); + benchmark::Shutdown(); app.close(); - return status; + return 0; } diff --git a/src/doc/algorithm/flip_benchmark.cpp b/src/doc/algorithm/flip_benchmark.cpp index 7e2afc086..3c9d984eb 100644 --- a/src/doc/algorithm/flip_benchmark.cpp +++ b/src/doc/algorithm/flip_benchmark.cpp @@ -1,5 +1,5 @@ // Aseprite Document Library -// Copyright (c) 2023 Igara Studio S.A. +// Copyright (c) 2023-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -22,7 +22,7 @@ void BM_FlipSlow(benchmark::State& state) { const int h = state.range(2); const auto ft = (doc::algorithm::FlipType)state.range(3); std::unique_ptr img(Image::create(pf, w, h)); - while (state.KeepRunning()) { + for (auto _ : state) { algorithm::flip_image_slow(img.get(), img->bounds(), ft); } } @@ -33,7 +33,7 @@ void BM_FlipRawPtr(benchmark::State& state) { const int h = state.range(2); const auto ft = (doc::algorithm::FlipType)state.range(3); std::unique_ptr img(Image::create(pf, w, h)); - while (state.KeepRunning()) { + for (auto _ : state) { algorithm::flip_image(img.get(), img->bounds(), ft); } } diff --git a/src/doc/algorithm/shrink_benchmark.cpp b/src/doc/algorithm/shrink_benchmark.cpp index 02346c33d..25057e95f 100644 --- a/src/doc/algorithm/shrink_benchmark.cpp +++ b/src/doc/algorithm/shrink_benchmark.cpp @@ -1,5 +1,5 @@ // Aseprite Document Library -// Copyright (c) 2019 Igara Studio S.A. +// Copyright (c) 2019-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -26,7 +26,7 @@ void BM_ShrinkBounds(benchmark::State& state) { std::unique_ptr img(Image::create(pixelFormat, w, h)); img->putPixel(w/2, h/2, rgba(1, 2, 3, 4)); gfx::Rect rc; - while (state.KeepRunning()) { + for (auto _ : state) { doc::algorithm::shrink_bounds(img.get(), 0, nullptr, rc); } } diff --git a/src/doc/blend_benchmark.cpp b/src/doc/blend_benchmark.cpp index 4dc0ff12e..e800397bd 100644 --- a/src/doc/blend_benchmark.cpp +++ b/src/doc/blend_benchmark.cpp @@ -1,4 +1,5 @@ // Aseprite Document Library +// Copyright (c) 2024 Igara Studio S.A. // Copyright (c) 2017 David Capello // // This file is released under the terms of the MIT license. @@ -30,7 +31,7 @@ void BM_Rgba(benchmark::State& state) { color_t b = color_t(state.range(1)); int opacity = state.range(2); BlendFunc func = F; - while (state.KeepRunning()) { + for (auto _ : state) { color_t c = func(a, b, opacity); c = func(c, b, opacity); } diff --git a/src/doc/primitives_benchmark.cpp b/src/doc/primitives_benchmark.cpp index 3f0d57674..57d181913 100644 --- a/src/doc/primitives_benchmark.cpp +++ b/src/doc/primitives_benchmark.cpp @@ -1,5 +1,5 @@ // Aseprite Document Library -// Copyright (c) 2023 Igara Studio S.A. +// Copyright (c) 2023-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -24,7 +24,7 @@ void BM_IsSameImageOld(benchmark::State& state) { ImageRef a(Image::create(pf, w, h)); doc::algorithm::random_image(a.get()); ImageRef b(Image::createCopy(a.get())); - while (state.KeepRunning()) { + for (auto _ : state) { is_same_image_slow(a.get(), b.get()); } } @@ -36,7 +36,7 @@ void BM_IsSameImageNew(benchmark::State& state) { ImageRef a(Image::create(pf, w, h)); doc::algorithm::random_image(a.get()); ImageRef b(Image::createCopy(a.get())); - while (state.KeepRunning()) { + for (auto _ : state) { is_same_image(a.get(), b.get()); } } diff --git a/src/render/render_benchmark.cpp b/src/render/render_benchmark.cpp index dfe1f52ae..15cfc1030 100644 --- a/src/render/render_benchmark.cpp +++ b/src/render/render_benchmark.cpp @@ -1,5 +1,5 @@ // Aseprite Document Library -// Copyright (c) 2019-2022 Igara Studio S.A. +// Copyright (c) 2019-2024 Igara Studio S.A. // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -54,7 +54,7 @@ static void Bm_Render(benchmark::State& state) std::unique_ptr dst(Image::create(spr->pixelFormat(), w, h)); clear_image(dst.get(), 0); - while (state.KeepRunning()) { + for (auto _ : state) { clear_image(dst.get(), 0); Render render; diff --git a/src/ui/view_benchmark.cpp b/src/ui/view_benchmark.cpp index d074f4a90..d5e4eda9b 100644 --- a/src/ui/view_benchmark.cpp +++ b/src/ui/view_benchmark.cpp @@ -28,7 +28,7 @@ void BM_ViewBase(benchmark::State& state) { mgr->layout(); mgr->dontWaitEvents(); - while (state.KeepRunning()) { + for (auto _ : state) { // Do nothing case mgr->generateMessages(); mgr->dispatchMessages(); @@ -51,7 +51,7 @@ void BM_ViewScrollListBox(benchmark::State& state) { const auto max = view->getScrollableSize(); int y = 0; - while (state.KeepRunning()) { + for (auto _ : state) { view->setViewScroll(gfx::Point(0, y)); mgr->generateMessages(); mgr->dispatchMessages(); @@ -89,8 +89,9 @@ int app_main(int argc, char* argv[]) window.addChild(g_view = new ui::View); window.openWindow(); - ::benchmark::Initialize(&argc, argv); - int status = ::benchmark::RunSpecifiedBenchmarks(); + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); + benchmark::Shutdown(); - return status; + return 0; } diff --git a/third_party/benchmark b/third_party/benchmark index 02a354f3f..c58e6d071 160000 --- a/third_party/benchmark +++ b/third_party/benchmark @@ -1 +1 @@ -Subproject commit 02a354f3f323ae8256948e1dc77ddcb1dfc297da +Subproject commit c58e6d0710581e3a08d65c349664128a8d9a2461