From 95c297ecf35b96ed862f7541d4c29d2ea2ba90b3 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Thu, 15 Oct 1998 23:34:32 +0000 Subject: [PATCH] little StatHist cleanup and debugging --- src/StatHist.cc | 31 ++++++++++++++++++++++--------- src/structs.h | 6 +++--- src/typedefs.h | 4 ++-- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/StatHist.cc b/src/StatHist.cc index cc84144a6d..7a720ba07f 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -1,6 +1,6 @@ /* - * $Id: StatHist.cc,v 1.15 1998/10/08 20:10:14 wessels Exp $ + * $Id: StatHist.cc,v 1.16 1998/10/15 17:34:32 wessels Exp $ * * DEBUG: section 62 Generic Histogram * AUTHOR: Duane Wessels @@ -48,14 +48,17 @@ #include "squid.h" /* Local functions */ -static void statHistInit(StatHist * H, int capacity, hbase_f val_in, hbase_f val_out, double min, double max); +static void statHistInit(StatHist * H, int capacity, hbase_f *val_in, hbase_f *val_out, double min, double max); static int statHistBin(const StatHist * H, double v); static double statHistVal(const StatHist * H, int bin); static StatHistBinDumper statHistBinDumper; +static hbase_f Log; +static hbase_f Exp; +static hbase_f Null; /* low level init, higher level functions has less params */ static void -statHistInit(StatHist * H, int capacity, hbase_f val_in, hbase_f val_out, double min, double max) +statHistInit(StatHist * H, int capacity, hbase_f *val_in, hbase_f *val_out, double min, double max) { assert(H); assert(capacity > 0); @@ -89,14 +92,24 @@ statHistClean(StatHist * H) void statHistCopy(StatHist * Dest, const StatHist * Orig) { - assert(Dest && Orig); + assert(Dest); + assert(Orig); + debug(62,3)("statHistCopy: Dest=%p, Orig=%p\n", Dest, Orig); assert(Dest->bins); /* better be safe than sorry */ assert(Dest->capacity == Orig->capacity); - assert(Dest->min == Orig->min && Dest->max == Orig->max); + assert(Dest->min == Orig->min); + assert(Dest->max == Orig->max); assert(Dest->scale == Orig->scale); - assert(Dest->val_in == Orig->val_in && Dest->val_out == Orig->val_out); + assert(Dest->val_in == Orig->val_in); + assert(Dest->val_out == Orig->val_out); + debug(62,3)("statHistCopy: capacity %d, min %f, max %f, scale %f\n", + Dest->capacity, Dest->min, Dest->max, Dest->scale); /* actual copy */ + debug(62,3)("statHistCopy: copying %d bytes to %p from %p\n", + Dest->capacity * sizeof(*Dest->bins), + Dest->bins, + Orig->bins); xmemcpy(Dest->bins, Orig->bins, Dest->capacity * sizeof(*Dest->bins)); } @@ -229,7 +242,7 @@ Exp(double x) void statHistLogInit(StatHist * H, int capacity, double min, double max) { - statHistInit(H, capacity, &Log, &Exp, min, max); + statHistInit(H, capacity, Log, Exp, min, max); } /* linear histogram for enums */ @@ -243,7 +256,7 @@ Null(double x) void statHistEnumInit(StatHist * H, int last_enum) { - statHistInit(H, last_enum + 3, &Null, &Null, (double) -1, (double) (last_enum + 1 + 1)); + statHistInit(H, last_enum + 3, Null, Null, (double) -1, (double) (last_enum + 1 + 1)); } void @@ -257,7 +270,7 @@ statHistEnumDumper(StoreEntry * sentry, int idx, double val, double size, int co void statHistIntInit(StatHist * H, int n) { - statHistInit(H, n, &Null, &Null, 0, n - 1); + statHistInit(H, n, Null, Null, 0, n - 1); } void diff --git a/src/structs.h b/src/structs.h index 503528200f..4e77f34b9b 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.240 1998/10/14 21:12:02 wessels Exp $ + * $Id: structs.h,v 1.241 1998/10/15 17:34:33 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1370,8 +1370,8 @@ struct _StatHist { double min; double max; double scale; - hbase_f val_in; /* e.g., log() for log-based histogram */ - hbase_f val_out; /* e.g., exp() for log based histogram */ + hbase_f *val_in; /* e.g., log() for log-based histogram */ + hbase_f *val_out; /* e.g., exp() for log based histogram */ }; /* diff --git a/src/typedefs.h b/src/typedefs.h index 3ef3790dc8..14cbd972f3 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.79 1998/10/10 14:57:44 wessels Exp $ + * $Id: typedefs.h,v 1.80 1998/10/15 17:34:34 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -200,7 +200,7 @@ typedef void STVLDCB(void *, int, int); typedef void HLPCB(void *, char *buf); typedef void HLPCMDOPTS(int *argc, char **argv); -typedef double (*hbase_f) (double); +typedef double hbase_f(double); typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, int count); /* append/vprintf's for Packer */ -- 2.47.2