From: Andrew Tridgell Date: Mon, 1 Apr 2002 02:59:06 +0000 (+0200) Subject: - added CCACHE_NOSTATS env variable X-Git-Tag: v1.3~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a70e277deb0dd3bcea98e9a43c1ac36ddbafc0a8;p=thirdparty%2Fccache.git - added CCACHE_NOSTATS env variable - added some more stats --- diff --git a/ccache.1 b/ccache.1 index 4a404870c..b9675b663 100644 --- a/ccache.1 +++ b/ccache.1 @@ -134,6 +134,11 @@ If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely\&. .IP +.IP "\fBCCACHE_NOSTATS\fP" +If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile\&. +.IP .IP "\fBCCACHE_NOUNIFY\fP" If you set the environment variable CCACHE_NOUNIFY then ccache will not use the C/C++ unifier when hashing diff --git a/ccache.c b/ccache.c index cdc5e8d26..13cd54f3d 100644 --- a/ccache.c +++ b/ccache.c @@ -475,12 +475,13 @@ static void process_args(int argc, char **argv) if (!input_file) { cc_log("No input file found\n"); - stats_update(STATS_ARGS); + stats_update(STATS_NOINPUT); failed(); } if (check_extension(input_file) != 0) { cc_log("Not a C/C++ file - %s\n", input_file); + stats_update(STATS_NOTC); failed(); } @@ -513,7 +514,7 @@ static void process_args(int argc, char **argv) /* cope with -o /dev/null */ if (stat(output_file, &st) == 0 && !S_ISREG(st.st_mode)) { cc_log("Not a regular file %s\n", output_file); - stats_update(STATS_ARGS); + stats_update(STATS_DEVICE); failed(); } } diff --git a/ccache.h b/ccache.h index 4f0857418..0a440baab 100644 --- a/ccache.h +++ b/ccache.h @@ -40,11 +40,13 @@ enum stats { STATS_CACHED, STATS_ARGS, STATS_LINK, - STATS_NUMFILES, STATS_TOTALSIZE, STATS_MAXFILES, STATS_MAXSIZE, + STATS_NOTC, + STATS_DEVICE, + STATS_NOINPUT, STATS_END }; diff --git a/ccache.yo b/ccache.yo index 38a80db6c..972eb1db2 100644 --- a/ccache.yo +++ b/ccache.yo @@ -114,6 +114,10 @@ dit(bf(CCACHE_DISABLE)) If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely. +dit(bf(CCACHE_NOSTATS)) If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile. + dit(bf(CCACHE_NOUNIFY)) If you set the environment variable CCACHE_NOUNIFY then ccache will not use the C/C++ unifier when hashing the pre-processor output. The unifier is slower than a normal hash, so diff --git a/stats.c b/stats.c index 341ecad87..2334174e0 100644 --- a/stats.c +++ b/stats.c @@ -29,34 +29,40 @@ extern char *cache_dir; #define STATS_VERSION 1 +#define FLAG_NOZERO 1 + static struct { enum stats stat; char *message; void (*fn)(unsigned ); -} stats_messages[] = { - { STATS_TOCACHE, "cache miss ", NULL }, - { STATS_CACHED, "cache hit ", NULL }, - { STATS_LINK, "called for link ", NULL }, - { STATS_STDOUT, "compiler produced stdout ", NULL }, - { STATS_STATUS, "compile failed ", NULL }, - { STATS_ERROR, "ccache internal error ", NULL }, - { STATS_PREPROCESSOR, "preprocessor error ", NULL }, - { STATS_COMPILER, "couldn't find the compiler ", NULL }, - { STATS_MISSING, "cache file missing ", NULL }, - { STATS_ARGS, "bad compiler arguments ", NULL }, - { STATS_NUMFILES, "files in cache ", NULL }, - { STATS_TOTALSIZE, "cache size ", display_size }, - { STATS_MAXFILES, "max files ", NULL }, - { STATS_MAXSIZE, "max cache size ", display_size }, - { STATS_NONE, NULL, NULL } + unsigned flags; +} stats_info[] = { + { STATS_CACHED, "cache hit ", NULL, 0 }, + { STATS_TOCACHE, "cache miss ", NULL, 0 }, + { STATS_LINK, "called for link ", NULL, 0 }, + { STATS_STDOUT, "compiler produced stdout ", NULL, 0 }, + { STATS_STATUS, "compile failed ", NULL, 0 }, + { STATS_ERROR, "ccache internal error ", NULL, 0 }, + { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 }, + { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 }, + { STATS_MISSING, "cache file missing ", NULL, 0 }, + { STATS_ARGS, "bad compiler arguments ", NULL, 0 }, + { STATS_NOTC, "not a C/C++ file ", NULL, 0 }, + { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, + { STATS_NOINPUT, "no input file ", NULL, 0 }, + { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO }, + { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO }, + { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO }, + { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO }, + { STATS_NONE, NULL, NULL, 0 } }; /* return a string description of a statistic */ -static int stats_message(enum stats stat) +static int stats_find(enum stats stat) { int i; - for (i=0;stats_messages[i].stat != STATS_NONE; i++) { - if (stats_messages[i].stat == stat) { + for (i=0;stats_info[i].stat != STATS_NONE; i++) { + if (stats_info[i].stat == stat) { return i; } } @@ -115,6 +121,8 @@ static void stats_update_size(enum stats stat, size_t size) unsigned counters[STATS_END]; int need_cleanup = 0; + if (getenv("CCACHE_NOSTATS")) return; + if (!stats_file) { if (!cache_dir) return; x_asprintf(&stats_file, "%s/stats", cache_dir); @@ -211,17 +219,17 @@ void stats_summary(void) } /* and display them */ - for (i=0;i

CCACHE_DISABLE
If you set the environment variable CCACHE_DISABLE then ccache will just call the real compiler, bypassing the cache completely. +

CCACHE_NOSTATS
If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile.

CCACHE_NOUNIFY
If you set the environment variable CCACHE_NOUNIFY then ccache will not use the C/C++ unifier when hashing the pre-processor output. The unifier is slower than a normal hash, so