[babl] babl: make pixel-count instrumentation opt-in
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] babl: make pixel-count instrumentation opt-in
- Date: Wed, 17 Jan 2018 02:50:50 +0000 (UTC)
commit 20d3b800dc7972897a5fa89bb664227c7d043111
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Jan 17 03:46:59 2018 +0100
babl: make pixel-count instrumentation opt-in
Checking if an integer is 0/1 is lower overhead than incrementing a long stored
kt a memory location. As a side effect, the entries in
~/.cache/babl/babl-fishes will not be sorted by most used to least used unless
the BABL_INSTRUMENT environment variable is set to a value.
babl/babl-fish-path.c | 15 ++++++++++++---
babl/babl-internal.h | 4 +++-
2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 867cb8d..eb10fe9 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -99,6 +99,7 @@ _babl_fish_create_name (char *buf,
static int max_path_length (void);
static int debug_conversions = 0;
+int _babl_instrument = 0;
double _babl_legal_error (void)
{
@@ -120,6 +121,12 @@ double _babl_legal_error (void)
else
debug_conversions = 0;
+ env = getenv ("BABL_INSTRUMENT");
+ if (env && env[0] != '\0')
+ _babl_instrument = 1;
+ else
+ _babl_instrument = 0;
+
return error;
}
@@ -732,8 +739,9 @@ _babl_process (const Babl *cbabl,
long n)
{
Babl *babl = (void*)cbabl;
- babl->fish.pixels += n;
babl->fish.dispatch (babl, source, destination, n, *babl->fish.data);
+ if (_babl_instrument)
+ babl->fish.pixels += n;
return n;
}
@@ -765,7 +773,8 @@ babl_process_rows (const Babl *fish,
if (n <= 0)
return 0;
- babl->fish.pixels += n * rows;
+ if (_babl_instrument)
+ babl->fish.pixels += n * rows;
for (row = 0; row < rows; row++)
{
babl->fish.dispatch (babl, (void*)src, (void*)dst, n, *babl->fish.data);
@@ -996,7 +1005,7 @@ get_path_instrumentation (FishPathInstrumentation *fpi,
process_conversion_path (path, fpi->source, source_bpp, fpi->destination,
dest_bpp, fpi->num_test_pixels);
ticks_end = babl_ticks ();
- *path_cost = ticks_end - ticks_start;
+ *path_cost = (ticks_end - ticks_start);
/* transform the reference and the actual destination buffers to RGBA
* for comparison with each other
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
index ff83795..415bc5e 100644
--- a/babl/babl-internal.h
+++ b/babl/babl-internal.h
@@ -483,6 +483,7 @@ void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz);
*/
void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
+extern int _babl_instrument;
static inline void
babl_conversion_process (const Babl *babl,
@@ -491,7 +492,8 @@ babl_conversion_process (const Babl *babl,
long n)
{
BablConversion *conversion = (BablConversion *) babl;
- conversion->pixels += n;
+ if (_babl_instrument)
+ conversion->pixels += n;
conversion->dispatch (babl, source, destination, n, conversion->data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]