sio_timer.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * All rights reserved.                                                      *
00004  *                                                                           *
00005  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00006  * terms governing use, modification, and redistribution, is contained in    *
00007  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00008  * of the source code distribution tree; Copyright.html can be found at the  *
00009  * root level of an installed copy of the electronic HDF5 document set and   *
00010  * is linked from the top-level documents page.  It can also be found at     *
00011  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00012  * access to either file, you may request a copy from help@hdfgroup.org.     *
00013  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00014 
00015 #ifndef SIO_TIMER__
00016 #define SIO_TIMER__
00017 
00018 #include "hdf5.h"
00019 
00020 #if defined(H5_TIME_WITH_SYS_TIME)
00021 #   include <sys/time.h>
00022 #   include <time.h>
00023 #elif defined(H5_HAVE_SYS_TIME_H)
00024 #   include <sys/time.h>
00025 #else
00026 #   include <time.h>
00027 #endif
00028 
00029 #ifdef _WIN32
00030 #       include <winsock.h>
00031 #endif /* _WIN32 */
00032 
00033 /* The different types of timers we can have */
00034 typedef enum timer_type_ {
00035     HDF5_FILE_OPENCLOSE,
00036     HDF5_DATASET_CREATE,
00037     HDF5_MPI_WRITE,
00038     HDF5_MPI_READ,
00039     HDF5_FILE_READ_OPEN,
00040     HDF5_FILE_READ_CLOSE,
00041     HDF5_FILE_WRITE_OPEN,
00042     HDF5_FILE_WRITE_CLOSE,
00043     HDF5_FINE_WRITE_FIXED_DIMS,
00044     HDF5_FINE_READ_FIXED_DIMS,
00045     HDF5_GROSS_WRITE_FIXED_DIMS,
00046     HDF5_GROSS_READ_FIXED_DIMS,
00047     HDF5_RAW_WRITE_FIXED_DIMS,
00048     HDF5_RAW_READ_FIXED_DIMS,
00049     NUM_TIMERS
00050 } timer_type;
00051 
00052 
00053 /* Miscellaneous identifiers */
00054 enum {
00055     START,          /* Start a specified timer              */
00056     STOP            /* Stop a specified timer               */
00057 };
00058 
00059 /* The performance time structure */
00060 typedef struct sio_time_ {
00061     double total_time[NUM_TIMERS];
00062     struct timeval sys_timer[NUM_TIMERS];
00063 } sio_time;
00064 
00065 /* External function declarations */
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif  /* __cplusplus */
00069 extern sio_time    *sio_time_new(void);
00070 extern void         sio_time_destroy(sio_time *pt);
00071 extern void         set_timer_type(sio_time *pt);
00072 extern sio_time    *set_time(sio_time *pt, timer_type t, int start_stop);
00073 extern double       get_time(sio_time *pt, timer_type t);
00074 #ifdef __cplusplus
00075 }
00076 #endif  /* __cplusplus */
00077 
00078 #endif  /* SIO_TIMER__ */