Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion src/libOpenImageIO/image_span_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <OpenImageIO/half.h>

#include <OpenImageIO/argparse.h>
#include <OpenImageIO/benchmark.h>
#include <OpenImageIO/fmath.h>
#include <OpenImageIO/imageio.h>
Expand All @@ -18,6 +19,9 @@
using namespace OIIO;


static int ntrials = 5;



template<typename T>
void
Expand Down Expand Up @@ -195,6 +199,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),
Expand Down Expand Up @@ -266,6 +271,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), [&]() {
Expand Down Expand Up @@ -332,6 +338,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),
Expand Down Expand Up @@ -418,6 +425,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;

Expand All @@ -442,6 +450,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)",
Expand Down Expand Up @@ -544,9 +553,36 @@ 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 --trials
// will override this, since it comes before the getargs() call.
ntrials = 1;
#endif

getargs(argc, argv);

test_image_span<float>();
test_image_span<const float>();
test_image_span<uint16_t>();
Expand Down
4 changes: 3 additions & 1 deletion src/libutil/simd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ getargs(int argc, char* argv[])
OIIO_INTRO_STRING)
.usage("simd_test [options]");

ap.arg("--iterations %d", &iterations)
ap.arg("--iters %d", &iterations)
.help(Strutil::fmt::format("Number of iterations (default: {})", iterations));
ap.arg("--iterations %d", &iterations)
.hidden(); // obsolete synonym for --iters
ap.arg("--trials %d", &ntrials)
.help("Number of trials");

Expand Down
Loading