From 67ad303d434164814bf110da0eddc1d49a135652 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 19 Jul 2019 16:04:07 +0100 Subject: [PATCH] add VIPS_PROFILE env var to enable profiling --- libvips/iofuncs/init.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 503fb7ae..1b6c058f 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -109,6 +109,10 @@ int vips__fatal = 0; */ GMutex *vips__global_lock = NULL; +/* A debugging timer, zero at library init. + */ +GTimer *vips__global_timer = NULL; + /* Keep a copy of the argv0 here. */ static char *vips__argv0 = NULL; @@ -371,7 +375,7 @@ vips_init( const char *argv0 ) #ifndef HAVE_THREAD_NEW if( !g_thread_supported() ) g_thread_init( NULL ); -#endif +#endif /*HAVE_THREAD_NEW*/ vips__threadpool_init(); vips__buffer_init(); @@ -385,6 +389,9 @@ vips_init( const char *argv0 ) if( !vips__global_lock ) vips__global_lock = vips_g_mutex_new(); + if( !vips__global_timer ) + vips__global_timer = g_timer_new(); + VIPS_SETSTR( vips__argv0, argv0 ); prgname = g_path_get_basename( argv0 ); @@ -419,6 +426,9 @@ vips_init( const char *argv0 ) g_getenv( "IM_INFO" ) ) vips_info_set( TRUE ); + if( g_getenv( "VIPS_PROFILE" ) ) + vips_profile_set( TRUE ); + /* Default various settings from env. */ if( g_getenv( "VIPS_TRACE" ) )