Changeset 68873b in git


Ignore:
Timestamp:
Mar 27, 1997, 11:23:55 AM (27 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '3720ae8bfcff4a4649ee98a15552089151d2d59b')
Children:
0bf9a278ad124abbaeec36c7244965e8baa71238
Parents:
7cebcbc39bd6be777d7bcda54de8ff5a5e031cf6
Message:
TIMING_END_AND_PRINT added
stream io replaced by std io
(hopefully) more portable now by using HZ
instead of CLK_TCK to calculate time in seconds


git-svn-id: file:///usr/local/Singular/svn/trunk@109 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/timing.h

    r7cebcb r68873b  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: timing.h,v 1.1 1996-12-06 14:49:07 schmidt Exp $ */
     2/* $Id: timing.h,v 1.2 1997-03-27 10:23:55 schmidt Exp $ */
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.1  1996/12/06 14:49:07  schmidt
     7Initial revision
     8
    69 * Revision 1.0  1996/05/17  10:59:37  stobbe
    710 * Initial revision
     
    1013
    1114/* It should be possible to include this file multiple times for different */
    12 /* settings of NDEBUG */
     15/* settings of TIMING */
    1316
    1417#undef TIMING_START
    1518#undef TIMING_END
     19#undef TIMING_END_AND_PRINT
    1620#undef TIMING_DEFINE_PRINT
    1721#undef TIMING_DEFINE_PRINTPROTO
     
    2125#include <time.h>
    2226#include <sys/times.h>
    23 #include <iostream.h>
     27#include <sys/param.h>
     28#include <stdio.h>
     29
     30// need to be adjusted on your machine:
     31// the number of ticks per second: HZ
     32#if ! defined (HZ) && defined (CLOCKS_PER_SEC)
     33#define HZ CLOCKS_PER_SEC
     34#endif
     35#if ! defined (HZ)  && defined (CLK_TCK)
     36#define HZ CLK_TCK
     37#endif
     38#ifndef HZ
     39#ifdef sun
     40#define HZ 60.0
     41#else
     42#define HZ 100.0
     43#endif
     44#endif
     45
    2446#define TIMING_START(t) { struct tms timing_ ## t ## _start, timing_ ## t ## _end; \
    2547  times( &timing_ ## t ## _start );
    2648#define TIMING_END(t) times( &timing_ ## t ## _end ); \
    2749  timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; }
     50#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
     51  fprintf( stderr, "%s%.2f sec\n", msg, \
     52           float( timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime ) / HZ ); \
     53  timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; }
    2854#define TIMING_DEFINE_PRINT(t) long timing_ ## t ## _time; \
    29 void timing_print_ ## t ( char * msg ) { cerr.setf( ios::fixed, ios::floatfield ); cerr.precision(2); \
    30   cerr << msg << float(timing_ ## t ## _time) / CLK_TCK << " sec" << endl; }
    31 #define TIMING_PRINT(t,msg) timing_print_ ## t ( msg );
     55void timing_print_ ## t ( char * msg ) { \
     56  fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
     57}
    3258#define TIMING_DEFINE_PRINTPROTO(t) void timing_print_ ## t ( char * );
    33 #else
     59#define TIMING_PRINT(t, msg) timing_print_ ## t ( msg );
     60#else /* TIMING */
    3461#define TIMING_START(t)
    3562#define TIMING_END(t)
     63#define TIMING_END_AND_PRINT(t, msg)
    3664#define TIMING_DEFINE_PRINT(t)
    37 #define TIMING_PRINT(t,msg)
    3865#define TIMING_DEFINE_PRINTPROTO(t)
     66#define TIMING_PRINT(t, msg)
    3967#endif /* TIMING */
Note: See TracChangeset for help on using the changeset viewer.