[poppler] poppler/goo: GooTimer.cc, NONE, 1.1 GooTimer.h, NONE, 1.1 Makefile.am, 1.1.1.1, 1.2

Jonathan Blandford jrb at freedesktop.org
Fri Apr 29 12:37:09 PDT 2005


Update of /cvs/poppler/poppler/goo
In directory gabe:/tmp/cvs-serv3321/goo

Modified Files:
	Makefile.am 
Added Files:
	GooTimer.cc GooTimer.h 
Log Message:
Fri Apr 29 14:54:44 2005  Jonathan Blandford  <jrb at redhat.com>

        * goo/GooTimer.h: New class to do simple timing checks.

        * glib/poppler-document.c: Patch from Martin Kretzschmar to really
        set the PDF version correct.  Third time's the charm.



--- NEW FILE: GooTimer.cc ---
//========================================================================
//
// GooTimer.cc
//
// Copyright 2005 Jonathan Blandford <jrb at redhat.com>
// Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team
//
//========================================================================

#include <config.h>

#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif

#include <string.h>
#include "GooTimer.h"

//------------------------------------------------------------------------
// GooTimer
//------------------------------------------------------------------------


GooTimer::GooTimer() {
  gettimeofday (&start, NULL);
  active = true;
}


void
GooTimer::stop() {
  gettimeofday (&end, NULL);
  active = false;
}

#define USEC_PER_SEC 1000000
double
GooTimer::getElapsed ()
{
  double total;
  struct timeval elapsed;

  if (active)
    gettimeofday (&end, NULL);

  if (start.tv_usec > end.tv_usec)
    {
      end.tv_usec += USEC_PER_SEC;
      end.tv_sec--;
    }

  elapsed.tv_usec = end.tv_usec - start.tv_usec;
  elapsed.tv_sec = end.tv_sec - start.tv_sec;

  total = elapsed.tv_sec + ((double) elapsed.tv_usec / 1e6);
  if (total < 0)
    {
      total = 0;
    }

  return total;
}


--- NEW FILE: GooTimer.h ---
//========================================================================
//
// GooList.h
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================

#ifndef GOOTIMER_H
#define GOOTIMER_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "gtypes.h"
#include <sys/time.h>

//------------------------------------------------------------------------
// GooList
//------------------------------------------------------------------------

class GooTimer {
public:

  // Create a new timer.
  GooTimer();

  void stop ();
  double getElapsed();


private:

	struct timeval start;
	struct timeval end;
	GBool active;
};

#endif

Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/goo/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Makefile.am	3 Mar 2005 19:45:58 -0000	1.1.1.1
+++ Makefile.am	29 Apr 2005 19:37:07 -0000	1.2
@@ -4,6 +4,7 @@
 poppler_goo_include_HEADERS =			\
 	GooHash.h				\
 	GooList.h				\
+	GooTimer.h				\
 	GooMutex.h				\
 	GooString.h				\
 	gmem.h					\
@@ -16,5 +17,6 @@
 	gmempp.cc				\
 	GooHash.cc				\
 	GooList.cc				\
+	GooTimer.cc				\
 	GooString.cc				\
 	gmem.c



More information about the poppler mailing list