aboutsummaryrefslogtreecommitdiff
path: root/generic/perfos.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/perfos.c')
-rw-r--r--generic/perfos.c137
1 files changed, 66 insertions, 71 deletions
diff --git a/generic/perfos.c b/generic/perfos.c
index 1b88255..f2f1d05 100644
--- a/generic/perfos.c
+++ b/generic/perfos.c
@@ -1,84 +1,46 @@
/*
- **********************************************************************************
- *
- * Project : Imagine
- * File : perfos.c
- * Version : $Id$
- * Author : Patrick LECOANET
- * Created On :
- * Purpose : Implementation of perf.
- *
- **********************************************************************************
- */
-
-/*
- *----------------- Distribution and Copyright --------------------------
- *
- * This software is copyright by the CENA/DGAC/FRANCE
- * All rights reserved.
- *
- * No part of the material protected by this copyright notice
- * may be reproduced or utilized for commercial use in any form
- * without written permission of the copyright owner.
+ * perfos.c -- Perfos modules.
*
- * It may be reproduced or utilized for R&D use in Non Profit
- * Organization.
+ * Authors : Patrick Lecoanet.
+ * Creation date :
*
- *-----------------------------------------------------------------------
+ * $Id$
*/
-
/*
- *----------------- Disclaimer ------------------------------------------
+ * Copyright (c) 1993 - 2000 CENA, Patrick Lecoanet --
*
- * This software and its documentation are provided "AS IS" and
- * without any expressed or implied warranties whatsoever.
- * No warranties as to performance, merchantability, or fitness
- * for a particular purpose exist.
+ * This code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * Because of the diversity of conditions and hardware under
- * which this software may be used, no warranty of fitness for
- * a particular purpose is offered. The user is advised to
- * test the software thoroughly before relying on it. The user
- * must assume the entire risk and liability of using this
- * software.
+ * This code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
*
- * In no event shall any person or organization of people be
- * held responsible for any direct, indirect, consequential
- * or inconsequential damages or lost profits.
+ * You should have received a copy of the GNU Library General Public
+ * License along with this code; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- *-----------------------------------------------------------------------
*/
-/*
- **********************************************************************************
- *
- * Incuded files.
- *
- **********************************************************************************
- */
-
#include "perfos.h"
#include "List.h"
+#include "Types.h"
+#include <X11/Xutil.h>
-/*
- **********************************************************************************
- *
- * Constants.
- *
- **********************************************************************************
- */
static const char rcsid[] = "$Id$";
-
-
-#ifdef PERFOS
+static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $";
static ZnList Chronos = NULL;
+
/*
**********************************************************************************
*
@@ -280,7 +242,7 @@ PrintChronos(void)
chrs = (Chrono *) ZnListArray(Chronos);
for (i = 0; i < cnt; i++) {
if (chrs[i]->actions != 0) {
- printf("%s : %d ms on %d times\n",
+ printf("%s : %ld ms on %d times\n",
chrs[i]->message,
chrs[i]->total_delay * 10 / chrs[i]->actions,
chrs[i]->actions);
@@ -292,21 +254,48 @@ PrintChronos(void)
/*
**********************************************************************************
*
- * ResetChronos - Reset all chronos registered so far.
+ * GetChrono - Return the number of runs and the total time of the Chrono.
*
**********************************************************************************
*/
void
-RazChronos(void)
+GetChrono(Chrono chrono,
+ long *time,
+ int *actions)
+{
+ if (time) {
+ *time = chrono->total_delay*10;
+ }
+ if (actions) {
+ *actions = chrono->actions;
+ }
+}
+
+
+/*
+ **********************************************************************************
+ *
+ * ResetChronos - Reset all chronos or only the specified.
+ *
+ **********************************************************************************
+ */
+void
+ResetChronos(Chrono chrono)
{
int i, cnt;
Chrono *chrs;
- cnt = ZnListSize(Chronos);
- chrs = (Chrono *) ZnListArray(Chronos);
- for (i = 0; i < cnt; i++) {
- chrs[i]->actions = 0;
- chrs[i]->total_delay = 0;
+ if (chrono) {
+ chrono->actions = 0;
+ chrono->total_delay = 0;
+ }
+ else {
+ cnt = ZnListSize(Chronos);
+ chrs = (Chrono *) ZnListArray(Chronos);
+ for (i = 0; i < cnt; i++) {
+ chrs[i]->actions = 0;
+ chrs[i]->total_delay = 0;
+ }
}
}
@@ -328,7 +317,7 @@ NewChrono(char *message)
Chronos = ZnListNew(8, sizeof(Chrono));
}
- new = (Chrono) malloc(sizeof(ChronoRec));
+ new = (Chrono) ZnMalloc(sizeof(ChronoRec));
new->actions = 0;
new->total_delay = 0;
new->message = message;
@@ -348,9 +337,15 @@ NewChrono(char *message)
void
FreeChrono(Chrono chrono)
{
- free(chrono);
+ int i;
+ Chrono *chrs = ZnListArray(Chronos);
+
+ ZnFree(chrono);
- ZnListDelete(Chronos, ZnListHead, &chrono);
+ for (i = ZnListSize(Chronos)-1; i >= 0; i--) {
+ if (chrs[i] == chrono) {
+ ZnListDelete(Chronos, i);
+ break;
+ }
+ }
}
-
-#endif /* PERFOS */