Skip to content

Commit 4aaaa73

Browse files
committed
int: Additional timing logging for performance investigations (#4506)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 6cfbedd commit 4aaaa73

5 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/libOpenImageIO/imagebuf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ ImageBufImpl::init_spec(string_view filename, int subimage, int miplevel,
10451045
&& m_current_subimage == subimage && m_current_miplevel == miplevel)
10461046
return true; // Already done
10471047

1048+
pvt::LoggedTimer logtime("IB::init_spec");
1049+
10481050
m_name = filename;
10491051

10501052
// If we weren't given an imagecache but "imagebuf:use_imagecache"
@@ -1219,6 +1221,7 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend,
12191221
return false;
12201222
}
12211223

1224+
pvt::LoggedTimer logtime("IB::read");
12221225
m_current_subimage = subimage;
12231226
m_current_miplevel = miplevel;
12241227
if (chend < 0 || chend > nativespec().nchannels)
@@ -1465,6 +1468,7 @@ ImageBuf::write(ImageOutput* out, ProgressCallback progress_callback,
14651468
}
14661469
bool ok = true;
14671470
ok &= m_impl->validate_pixels();
1471+
pvt::LoggedTimer("IB::write inner");
14681472
if (out->supports("thumbnail") && has_thumbnail()) {
14691473
auto thumb = get_thumbnail();
14701474
// Strutil::print("IB::write: has thumbnail ROI {}\n", thumb->roi());
@@ -1581,6 +1585,7 @@ ImageBuf::write(string_view _filename, TypeDesc dtype, string_view _fileformat,
15811585
ProgressCallback progress_callback,
15821586
void* progress_callback_data) const
15831587
{
1588+
pvt::LoggedTimer("IB::write");
15841589
string_view filename = _filename.size() ? _filename : string_view(name());
15851590
string_view fileformat = _fileformat.size() ? _fileformat : filename;
15861591
if (filename.size() == 0) {

src/libOpenImageIO/imagebufalgo_copy.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ ImageBufAlgo::crop(const ImageBuf& src, ROI roi, int nthreads)
307307
bool
308308
ImageBufAlgo::cut(ImageBuf& dst, const ImageBuf& src, ROI roi, int nthreads)
309309
{
310-
pvt::LoggedTimer logtime("IBA::cut");
310+
// pvt::LoggedTimer logtime("IBA::cut");
311+
// Don't log, because all the work is inside crop, which already logs
311312
bool ok = crop(dst, src, roi, nthreads);
312313
if (!ok)
313314
return false;

src/libOpenImageIO/imageinput.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ ImageInput::read_scanlines(int subimage, int miplevel, int ybegin, int yend,
287287
int z, int chbegin, int chend, TypeDesc format,
288288
void* data, stride_t xstride, stride_t ystride)
289289
{
290+
pvt::LoggedTimer logtime("II::read_scanlines");
290291
ImageSpec spec;
291292
int rps = 0;
292293
{
@@ -845,6 +846,7 @@ ImageInput::read_image(int subimage, int miplevel, int chbegin, int chend,
845846
ProgressCallback progress_callback,
846847
void* progress_callback_data)
847848
{
849+
pvt::LoggedTimer logtime("II::read_image");
848850
ImageSpec spec;
849851
int rps = 0;
850852
{

src/libOpenImageIO/imageoutput.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ ImageOutput::write_image(TypeDesc format, const void* data, stride_t xstride,
487487
ProgressCallback progress_callback,
488488
void* progress_callback_data)
489489
{
490+
pvt::LoggedTimer("ImageOutput::write image");
490491
bool native = (format == TypeDesc::UNKNOWN);
491492
stride_t pixel_bytes = native ? (stride_t)m_spec.pixel_bytes(native)
492493
: format.size() * m_spec.nchannels;

src/tiff.imageio/tiffoutput.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <OpenImageIO/tiffutils.h>
2424
#include <OpenImageIO/timer.h>
2525

26+
#include "imageio_pvt.h"
27+
2628

2729
// clang-format off
2830
#ifdef TIFFLIB_MAJOR_VERSION
@@ -1340,6 +1342,7 @@ TIFFOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format,
13401342
const void* data, stride_t xstride,
13411343
stride_t ystride)
13421344
{
1345+
pvt::LoggedTimer("TIFFOutput::write_scanlines");
13431346
// If the stars all align properly, try to write strips, and use the
13441347
// thread pool to parallelize the compression. This can give a large
13451348
// speedup (5x or more!) because the zip compression dwarfs the
@@ -1566,6 +1569,7 @@ TIFFOutput::write_tiles(int xbegin, int xend, int ybegin, int yend, int zbegin,
15661569
int zend, TypeDesc format, const void* data,
15671570
stride_t xstride, stride_t ystride, stride_t zstride)
15681571
{
1572+
pvt::LoggedTimer("TIFFOutput::write_tiles");
15691573
if (!m_spec.valid_tile_range(xbegin, xend, ybegin, yend, zbegin, zend))
15701574
return false;
15711575

0 commit comments

Comments
 (0)