-
Notifications
You must be signed in to change notification settings - Fork 647
test: image_span_test reduce benchmark load for debug and CI renders #4951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
|
|
||
| #include <OpenImageIO/half.h> | ||
|
|
||
| #include <OpenImageIO/argparse.h> | ||
| #include <OpenImageIO/benchmark.h> | ||
| #include <OpenImageIO/fmath.h> | ||
| #include <OpenImageIO/imageio.h> | ||
|
|
@@ -18,6 +19,10 @@ | |
| using namespace OIIO; | ||
|
|
||
|
|
||
| static int iterations = 0; // 1000000; | ||
| static int ntrials = 5; | ||
|
|
||
|
|
||
|
|
||
| template<typename T> | ||
| void | ||
|
|
@@ -195,6 +200,7 @@ test_image_span_copy_image() | |
|
|
||
| // Benchmark old (ptr) versus new (span) copy_image functions | ||
| Benchmarker bench; | ||
| bench.trials(ntrials); | ||
| bench.units(Benchmarker::Unit::us); | ||
|
|
||
| bench(Strutil::format(" copy_image image_span {}", label), | ||
|
|
@@ -266,6 +272,7 @@ test_image_span_contiguize() | |
|
|
||
| // Benchmark old (ptr) versus new (span) contiguize functions | ||
| Benchmarker bench; | ||
| bench.trials(ntrials); | ||
| bench.units(Benchmarker::Unit::us); | ||
|
|
||
| bench(Strutil::format(" contiguize image_span {}", label), [&]() { | ||
|
|
@@ -332,6 +339,7 @@ test_image_span_convert_image() | |
|
|
||
| // Benchmark old (ptr) versus new (span) contiguize functions | ||
| Benchmarker bench; | ||
| bench.trials(ntrials); | ||
| bench.units(Benchmarker::Unit::ms); | ||
|
|
||
| bench(Strutil::format(" convert_image image_span {}", label), | ||
|
|
@@ -418,6 +426,7 @@ benchmark_image_span_passing() | |
| image_span<const float> ispan(sbuf.data(), nchans, xres, yres, 1); | ||
|
|
||
| Benchmarker bench; | ||
| bench.trials(ntrials); | ||
| bench.units(Benchmarker::Unit::us); | ||
| float sum = 0.0f; | ||
|
|
||
|
|
@@ -442,6 +451,7 @@ benchmark_image_span_passing() | |
|
|
||
| // Do it all again for a SMALL image | ||
| bench.units(Benchmarker::Unit::ns); | ||
| bench.trials(ntrials); | ||
| int small = 16; | ||
| image_span<const float> smispan(sbuf.data(), nchans, small, small, 1); | ||
| bench(" pass by value (small)", | ||
|
|
@@ -544,9 +554,37 @@ test_image_span_within_span() | |
|
|
||
|
|
||
|
|
||
| static void | ||
| getargs(int argc, char* argv[]) | ||
| { | ||
| ArgParse ap; | ||
| ap.intro( | ||
| "image_span_test -- unit test and benchmarks for OpenImageIO/image_span.h\n" OIIO_INTRO_STRING) | ||
| .usage("image_span_test [options]"); | ||
|
|
||
| ap.arg("--iterations %d", &iterations) | ||
|
||
| .help(Strutil::fmt::format("Number of iterations (default: {})", | ||
| iterations)); | ||
| ap.arg("--trials %d", &ntrials).help("Number of trials"); | ||
|
|
||
| ap.parse_args(argc, (const char**)argv); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| int | ||
| main(int /*argc*/, char* /*argv*/[]) | ||
| main(int argc, char* argv[]) | ||
| { | ||
| #if !defined(NDEBUG) || defined(OIIO_CI) || defined(OIIO_CODE_COVERAGE) | ||
| // For the sake of test time, reduce the default iterations for DEBUG, | ||
| // CI, and code coverage builds. Explicit use of --iters or --trials | ||
| // will override this, since it comes before the getargs() call. | ||
| iterations /= 10; | ||
| ntrials = 1; | ||
| #endif | ||
|
|
||
| getargs(argc, argv); | ||
|
|
||
| test_image_span<float>(); | ||
| test_image_span<const float>(); | ||
| test_image_span<uint16_t>(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
iterationsis unused. It's only set, but never passed into something likebench.iterations(...)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing