-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project: added ut and benchmark targets.
Signed-off-by: Bartłomiej Burdukiewicz <[email protected]>
- Loading branch information
Showing
6 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.user | ||
*.pro.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
#include <src/gcode-generator.hpp> | ||
#include <src/semi-gcode.hpp> | ||
|
||
#include <QApplication> | ||
#include <QImage> | ||
#include <QPixmap> | ||
|
||
auto create_image() -> QImage { | ||
QPixmap ret(256, 256); | ||
ret.fill(Qt::black); | ||
return ret.toImage(); | ||
} | ||
|
||
static void generate_semi_gcode_from_image(benchmark::State &state) { | ||
const auto image = create_image(); | ||
progress_t progress{}; | ||
while (state.KeepRunning()) { | ||
auto ret = semi::generator::from_image(image, {}, progress); | ||
benchmark::DoNotOptimize(ret); | ||
} | ||
} | ||
|
||
BENCHMARK(generate_semi_gcode_from_image); | ||
|
||
auto main(int argc, char **argv) -> int { | ||
QApplication app(argc, argv); | ||
::benchmark::Initialize(&argc, argv); | ||
::benchmark::RunSpecifiedBenchmarks(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <src/gcode-generator.hpp> | ||
#include <src/instructions.hpp> | ||
#include <src/semi-gcode.hpp> | ||
|
||
#include <QImage> | ||
#include <QPixmap> | ||
|
||
auto create_image() -> QImage { | ||
QPixmap ret(256, 256); | ||
ret.fill(Qt::black); | ||
return ret.toImage(); | ||
} | ||
|
||
TEST(semi_generator, from_image) { | ||
auto progress = progress_t{}; | ||
const auto image = create_image(); | ||
const auto codes = semi::generator::from_image(image, {}, progress); | ||
EXPECT_GE(codes.size(), image.width() * image.height()); | ||
EXPECT_DOUBLE_EQ(progress, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <gtest/gtest.h> | ||
#include <QApplication> | ||
|
||
int main(int argc, char *argv[]) { | ||
QApplication app(argc, argv); | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |