Use clock() when times() is not available.
* configure.ac: Check for times() and sys/times.h. * src/misc/timer.hh: Include sys/times.h conditionally and use clock() if times() is not available. Reported by Yann Thierry-Mieg.
This commit is contained in:
parent
8620138069
commit
2c8e5297e7
2 changed files with 21 additions and 6 deletions
|
|
@ -67,7 +67,8 @@ AX_CHECK_LBTT
|
||||||
AX_CHECK_GSPNLIB
|
AX_CHECK_GSPNLIB
|
||||||
AX_CHECK_BOOST([1.34], [103400])
|
AX_CHECK_BOOST([1.34], [103400])
|
||||||
|
|
||||||
AC_CHECK_FUNCS([srand48 drand48])
|
AC_CHECK_HEADERS([sys/times.h])
|
||||||
|
AC_CHECK_FUNCS([times srand48 drand48])
|
||||||
|
|
||||||
LT_CONFIG_LTDL_DIR([ltdl])
|
LT_CONFIG_LTDL_DIR([ltdl])
|
||||||
LT_INIT([win32-dll])
|
LT_INIT([win32-dll])
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
// Copyright (C) 2009, 2011 Laboratoire de Recherche et Developpement
|
// -*- coding: utf-8 -*-
|
||||||
// de l'Epita (LRDE).
|
// Copyright (C) 2009, 2011, 2012 Laboratoire de Recherche et
|
||||||
|
// Développement de l'Epita (LRDE).
|
||||||
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -24,11 +25,16 @@
|
||||||
#ifndef SPOT_MISC_TIMER_HH
|
#ifndef SPOT_MISC_TIMER_HH
|
||||||
# define SPOT_MISC_TIMER_HH
|
# define SPOT_MISC_TIMER_HH
|
||||||
|
|
||||||
|
# include "misc/_config.h"
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
# include <iosfwd>
|
# include <iosfwd>
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <map>
|
# include <map>
|
||||||
# include <sys/times.h>
|
# if SPOT_HAVE_SYS_TIMES_H
|
||||||
|
# include <sys/times.h>
|
||||||
|
# endif
|
||||||
|
# include <ctime>
|
||||||
|
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +45,7 @@ namespace spot
|
||||||
struct time_info
|
struct time_info
|
||||||
{
|
{
|
||||||
time_info()
|
time_info()
|
||||||
: utime(), stime(0)
|
: utime(0), stime(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
clock_t utime;
|
clock_t utime;
|
||||||
|
|
@ -61,20 +67,28 @@ namespace spot
|
||||||
{
|
{
|
||||||
assert(!running);
|
assert(!running);
|
||||||
running = true;
|
running = true;
|
||||||
|
#ifdef SPOT_HAVE_TIMES
|
||||||
struct tms tmp;
|
struct tms tmp;
|
||||||
times(&tmp);
|
times(&tmp);
|
||||||
start_.utime = tmp.tms_utime;
|
start_.utime = tmp.tms_utime;
|
||||||
start_.stime = tmp.tms_stime;
|
start_.stime = tmp.tms_stime;
|
||||||
|
#else
|
||||||
|
start_.utime = clock();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stop a time interval and update the sum of all intervals.
|
/// Stop a time interval and update the sum of all intervals.
|
||||||
void
|
void
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
|
#ifdef SPOT_HAVE_TIMES
|
||||||
struct tms tmp;
|
struct tms tmp;
|
||||||
times(&tmp);
|
times(&tmp);
|
||||||
total_.utime += tmp.tms_utime - start_.utime;
|
total_.utime += tmp.tms_utime - start_.utime;
|
||||||
total_.stime += tmp.tms_stime - start_.stime;
|
total_.stime += tmp.tms_stime - start_.stime;
|
||||||
|
#else
|
||||||
|
total_.utime += clock() - start_.utime;
|
||||||
|
#endif
|
||||||
assert(running);
|
assert(running);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue