From b526286d403ffb57824eac4814d0c4a5271882c2 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 13 Jan 2023 11:42:26 +0100 Subject: [PATCH] pstats: Add collectors for texture/image reading/writing --- panda/src/gobj/texture.cxx | 3 +++ panda/src/gobj/texture.h | 1 + panda/src/pnmimage/pnmImage.cxx | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 995549cb5c..d84cd4ca93 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -70,6 +70,7 @@ ConfigVariableEnum texture_quality_level "renderers. See Texture::set_quality_level().")); PStatCollector Texture::_texture_read_pcollector("*:Texture:Read"); +PStatCollector Texture::_texture_write_pcollector("*:Texture:Write"); TypeHandle Texture::_type_handle; TypeHandle Texture::CData::_type_handle; AutoTextureScale Texture::_textures_power_2 = ATS_unspecified; @@ -5198,6 +5199,8 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) bool Texture:: do_write(CData *cdata, const Filename &fullpath, int z, int n, bool write_pages, bool write_mipmaps) { + PStatTimer timer(_texture_write_pcollector); + if (is_txo_filename(fullpath)) { if (!do_has_bam_rawdata(cdata)) { do_get_bam_rawdata(cdata); diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 1aef0c0b2f..d1e3b1ecb4 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -1088,6 +1088,7 @@ private: static AutoTextureScale _textures_power_2; static PStatCollector _texture_read_pcollector; + static PStatCollector _texture_write_pcollector; // Datagram stuff public: diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 428344b33f..7f4c32c558 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -19,11 +19,16 @@ #include "config_pnmimage.h" #include "perlinNoise2.h" #include "stackedPerlinNoise2.h" +#include "pStatCollector.h" +#include "pStatTimer.h" #include using std::max; using std::min; +static PStatCollector _image_read_pcollector("*:PNMImage:read"); +static PStatCollector _image_write_pcollector("*:PNMImage:write"); + /** * */ @@ -319,6 +324,8 @@ read(std::istream &data, const std::string &filename, PNMFileType *type, */ bool PNMImage:: read(PNMReader *reader) { + PStatTimer timer(_image_read_pcollector); + bool has_read_size = _has_read_size; int read_x_size = _read_x_size; int read_y_size = _read_y_size; @@ -437,6 +444,8 @@ write(PNMWriter *writer) const { return false; } + PStatTimer timer(_image_write_pcollector); + writer->copy_header_from(*this); if (!writer->supports_integer()) {