gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 5 2
merge default
5 files changed with 186 insertions and 68 deletions:
↑ Collapse diff ↑
Show white space 48 line context
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library.
4
 *
5
 * Copyright (C) 2003-2009
6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8
 *
9
 * Permission to use, modify and distribute this software is granted
10
 * provided that this copyright notice appears in all copies. For
11
 * precise terms see the accompanying LICENSE file.
12
 *
13
 * This software is provided "AS IS" with no warranty of any kind,
14
 * express or implied, and with no claim as to its suitability for any
15
 * purpose.
16
 *
17
 */
18

	
19
///\file
20
///\brief Some basic non-inline functions and static global data.
21

	
22
#include<lemon/bits/windows.h>
23

	
24
#ifdef WIN32
25
#ifndef WIN32_LEAN_AND_MEAN
26
#define WIN32_LEAN_AND_MEAN
27
#endif
28
#ifndef NOMINMAX
29
#define NOMINMAX
30
#endif
31
#include <windows.h>
32
#else
33
#include <unistd.h>
34
#include <ctime>
35
#include <sys/times.h>
36
#include <sys/time.h>
37
#endif
38

	
39
#include <cmath>
40
#include <sstream>
41

	
42
namespace lemon {
43
  namespace bits {
44
    void getWinProcTimes(double &rtime,
45
                         double &utime, double &stime,
46
                         double &cutime, double &cstime)
47
    {
48
#ifdef WIN32
49
      static const double ch = 4294967296.0e-7;
50
      static const double cl = 1.0e-7;
51

	
52
      FILETIME system;
53
      GetSystemTimeAsFileTime(&system);
54
      rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
55

	
56
      FILETIME create, exit, kernel, user;
57
      if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
58
        utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
59
        stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
60
        cutime = 0;
61
        cstime = 0;
62
      } else {
63
        rtime = 0;
64
        utime = 0;
65
        stime = 0;
66
        cutime = 0;
67
        cstime = 0;
68
      }
69
#else
70
      timeval tv;
71
      gettimeofday(&tv, 0);
72
      rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
73

	
74
      tms ts;
75
      double tck=sysconf(_SC_CLK_TCK);
76
      times(&ts);
77
      utime=ts.tms_utime/tck;
78
      stime=ts.tms_stime/tck;
79
      cutime=ts.tms_cutime/tck;
80
      cstime=ts.tms_cstime/tck;
81
#endif
82
    }
83

	
84
    std::string getWinFormattedDate()
85
    {
86
      std::ostringstream os;
87
#ifdef WIN32
88
      SYSTEMTIME time;
89
      GetSystemTime(&time);
90
#if defined(_MSC_VER) && (_MSC_VER < 1500)
91
      LPWSTR buf1, buf2, buf3;
92
      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
93
                        L"ddd MMM dd", buf1, 11) &&
94
          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
95
                        L"HH':'mm':'ss", buf2, 9) &&
96
          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
97
                        L"yyyy", buf3, 5)) {
98
        os << buf1 << ' ' << buf2 << ' ' << buf3;
99
      }
100
#else
101
      char buf1[11], buf2[9], buf3[5];
102
      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
103
                        "ddd MMM dd", buf1, 11) &&
104
          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
105
                        "HH':'mm':'ss", buf2, 9) &&
106
          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
107
                        "yyyy", buf3, 5)) {
108
        os << buf1 << ' ' << buf2 << ' ' << buf3;
109
      }
110
#endif
111
      else os << "unknown";
112
#else
113
      timeval tv;
114
      gettimeofday(&tv, 0);
115

	
116
      char cbuf[26];
117
      ctime_r(&tv.tv_sec,cbuf);
118
      os << cbuf;
119
#endif
120
      return os.str();
121
    }
122

	
123
    int getWinRndSeed()
124
    {
125
#ifdef WIN32
126
      FILETIME time;
127
      GetSystemTimeAsFileTime(&time);
128
      return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime;
129
#else
130
      timeval tv;
131
      gettimeofday(&tv, 0);
132
      return getpid() + tv.tv_sec + tv.tv_usec;
133
#endif
134
    }
135
  }
136
}
Show white space 48 line context
1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2
 *
3
 * This file is a part of LEMON, a generic C++ optimization library.
4
 *
5
 * Copyright (C) 2003-2009
6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8
 *
9
 * Permission to use, modify and distribute this software is granted
10
 * provided that this copyright notice appears in all copies. For
11
 * precise terms see the accompanying LICENSE file.
12
 *
13
 * This software is provided "AS IS" with no warranty of any kind,
14
 * express or implied, and with no claim as to its suitability for any
15
 * purpose.
16
 *
17
 */
18

	
19
#ifndef LEMON_WINDOWS_H
20
#define LEMON_WINDOWS_H
21

	
22
#include <string>
23

	
24
namespace lemon {
25
  namespace bits {
26
    void getWinProcTimes(double &rtime,
27
                         double &utime, double &stime,
28
                         double &cutime, double &cstime);
29
    std::string getWinFormattedDate();
30
    int getWinRndSeed();
31
  }
32
}
33

	
34
#endif
Show white space 48 line context
1 1
INCLUDE_DIRECTORIES(
2 2
  ${CMAKE_SOURCE_DIR}
3 3
  ${CMAKE_BINARY_DIR}
4 4
)
5 5

	
6 6
CONFIGURE_FILE(
7 7
  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
8 8
  ${CMAKE_CURRENT_BINARY_DIR}/config.h
9 9
)
10 10

	
11 11
SET(LEMON_SOURCES
12 12
  arg_parser.cc
13 13
  base.cc
14 14
  color.cc
15 15
  lp_base.cc
16 16
  lp_skeleton.cc
17
  random.cc)
17
  random.cc
18
  bits/windows.cc
19
)
18 20

	
19 21
IF(HAVE_GLPK)
20 22
  SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc)
21 23
  INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIR})
22 24
  IF(WIN32)
23 25
    INSTALL(FILES ${GLPK_BIN_DIR}/glpk.dll DESTINATION bin)
24 26
    INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin)
25 27
    INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin)
26 28
  ENDIF(WIN32)
27 29
ENDIF(HAVE_GLPK)
28 30

	
29 31
ADD_LIBRARY(lemon ${LEMON_SOURCES})
30 32

	
31 33
INSTALL(
32 34
  TARGETS lemon
33 35
  ARCHIVE DESTINATION lib
34 36
  COMPONENT library)
35 37

	
36 38
INSTALL(
37 39
  DIRECTORY . bits concepts
38 40
  DESTINATION include/lemon
39 41
  COMPONENT headers
40 42
  FILES_MATCHING PATTERN "*.h")
Show white space 48 line context
1 1
EXTRA_DIST += \
2 2
	lemon/lemon.pc.in \
3 3
	lemon/CMakeLists.txt
4 4

	
5 5
pkgconfig_DATA += lemon/lemon.pc
6 6

	
7 7
lib_LTLIBRARIES += lemon/libemon.la
8 8

	
9 9
lemon_libemon_la_SOURCES = \
10 10
	lemon/arg_parser.cc \
11 11
	lemon/base.cc \
12 12
	lemon/color.cc \
13 13
	lemon/lp_base.cc \
14 14
	lemon/lp_skeleton.cc \
15
	lemon/random.cc
15
        lemon/random.cc \
16
	lemon/bits/windows.cc
16 17

	
17 18

	
18 19
lemon_libemon_la_CXXFLAGS = \
19 20
	$(GLPK_CFLAGS) \
20 21
	$(CPLEX_CFLAGS) \
21 22
	$(SOPLEX_CXXFLAGS) \
22 23
	$(CLP_CXXFLAGS)
23 24

	
24 25
lemon_libemon_la_LDFLAGS = \
25 26
	$(GLPK_LIBS) \
26 27
	$(CPLEX_LIBS) \
27 28
	$(SOPLEX_LIBS) \
28 29
	$(CLP_LIBS)
29 30

	
30 31
if HAVE_GLPK
31 32
lemon_libemon_la_SOURCES += lemon/glpk.cc
32 33
endif
33 34

	
34 35
if HAVE_CPLEX
35 36
lemon_libemon_la_SOURCES += lemon/cplex.cc
36 37
endif
37 38

	
38 39
if HAVE_SOPLEX
39 40
lemon_libemon_la_SOURCES += lemon/soplex.cc
... ...
@@ -69,49 +70,50 @@
69 70
	lemon/grid_graph.h \
70 71
	lemon/hypercube_graph.h \
71 72
	lemon/kruskal.h \
72 73
	lemon/hao_orlin.h \
73 74
	lemon/lgf_reader.h \
74 75
	lemon/lgf_writer.h \
75 76
	lemon/list_graph.h \
76 77
	lemon/lp.h \
77 78
	lemon/lp_base.h \
78 79
	lemon/lp_skeleton.h \
79 80
	lemon/list_graph.h \
80 81
	lemon/maps.h \
81 82
	lemon/math.h \
82 83
	lemon/max_matching.h \
83 84
	lemon/nauty_reader.h \
84 85
	lemon/path.h \
85 86
	lemon/preflow.h \
86 87
	lemon/radix_sort.h \
87 88
	lemon/random.h \
88 89
	lemon/smart_graph.h \
89 90
	lemon/soplex.h \
90 91
	lemon/suurballe.h \
91 92
	lemon/time_measure.h \
92 93
	lemon/tolerance.h \
93
	lemon/unionfind.h
94
	lemon/unionfind.h \
95
	lemon/bits/windows.h
94 96

	
95 97
bits_HEADERS += \
96 98
	lemon/bits/alteration_notifier.h \
97 99
	lemon/bits/array_map.h \
98 100
	lemon/bits/base_extender.h \
99 101
	lemon/bits/bezier.h \
100 102
	lemon/bits/default_map.h \
101 103
	lemon/bits/edge_set_extender.h \
102 104
	lemon/bits/enable_if.h \
103 105
	lemon/bits/graph_adaptor_extender.h \
104 106
	lemon/bits/graph_extender.h \
105 107
	lemon/bits/map_extender.h \
106 108
	lemon/bits/path_dump.h \
107 109
	lemon/bits/solver_bits.h \
108 110
	lemon/bits/traits.h \
109 111
	lemon/bits/variant.h \
110 112
	lemon/bits/vector_map.h
111 113

	
112 114
concept_HEADERS += \
113 115
	lemon/concepts/digraph.h \
114 116
	lemon/concepts/graph.h \
115 117
	lemon/concepts/graph_components.h \
116 118
	lemon/concepts/heap.h \
117 119
	lemon/concepts/maps.h \
Show white space 48 line context
... ...
@@ -8,55 +8,49 @@
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_GRAPH_TO_EPS_H
20 20
#define LEMON_GRAPH_TO_EPS_H
21 21

	
22 22
#include<iostream>
23 23
#include<fstream>
24 24
#include<sstream>
25 25
#include<algorithm>
26 26
#include<vector>
27 27

	
28 28
#ifndef WIN32
29 29
#include<sys/time.h>
30 30
#include<ctime>
31 31
#else
32
#ifndef WIN32_LEAN_AND_MEAN
33
#define WIN32_LEAN_AND_MEAN
34
#endif
35
#ifndef NOMINMAX
36
#define NOMINMAX
37
#endif
38
#include<windows.h>
32
#include<lemon/bits/windows.h>
39 33
#endif
40 34

	
41 35
#include<lemon/math.h>
42 36
#include<lemon/core.h>
43 37
#include<lemon/dim2.h>
44 38
#include<lemon/maps.h>
45 39
#include<lemon/color.h>
46 40
#include<lemon/bits/bezier.h>
47 41
#include<lemon/error.h>
48 42

	
49 43

	
50 44
///\ingroup eps_io
51 45
///\file
52 46
///\brief A well configurable tool for visualizing graphs
53 47

	
54 48
namespace lemon {
55 49

	
56 50
  namespace _graph_to_eps_bits {
57 51
    template<class MT>
58 52
    class _NegY {
59 53
    public:
60 54
      typedef typename MT::Key Key;
61 55
      typedef typename MT::Value Value;
62 56
      const MT &map;
... ...
@@ -662,83 +656,61 @@
662 656
  }
663 657

	
664 658
public:
665 659
  ~GraphToEps() { }
666 660

	
667 661
  ///Draws the graph.
668 662

	
669 663
  ///Like other functions using
670 664
  ///\ref named-templ-func-param "named template parameters",
671 665
  ///this function calls the algorithm itself, i.e. in this case
672 666
  ///it draws the graph.
673 667
  void run() {
674 668
    const double EPSILON=1e-9;
675 669
    if(dontPrint) return;
676 670

	
677 671
    _graph_to_eps_bits::_NegY<typename T::CoordsMapType>
678 672
      mycoords(_coords,_negY);
679 673

	
680 674
    os << "%!PS-Adobe-2.0 EPSF-2.0\n";
681 675
    if(_title.size()>0) os << "%%Title: " << _title << '\n';
682 676
     if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
683 677
    os << "%%Creator: LEMON, graphToEps()\n";
684 678

	
685 679
    {
680
      os << "%%CreationDate: ";
686 681
#ifndef WIN32
687 682
      timeval tv;
688 683
      gettimeofday(&tv, 0);
689 684

	
690 685
      char cbuf[26];
691 686
      ctime_r(&tv.tv_sec,cbuf);
692
      os << "%%CreationDate: " << cbuf;
687
      os << cbuf;
693 688
#else
694
      SYSTEMTIME time;
695
      GetSystemTime(&time);
696
#if defined(_MSC_VER) && (_MSC_VER < 1500)
697
      LPWSTR buf1, buf2, buf3;
698
      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
699
                        L"ddd MMM dd", buf1, 11) &&
700
          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
701
                        L"HH':'mm':'ss", buf2, 9) &&
702
          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
703
                        L"yyyy", buf3, 5)) {
704
        os << "%%CreationDate: " << buf1 << ' '
705
           << buf2 << ' ' << buf3 << std::endl;
706
      }
707
#else
708
        char buf1[11], buf2[9], buf3[5];
709
        if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
710
                          "ddd MMM dd", buf1, 11) &&
711
            GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
712
                          "HH':'mm':'ss", buf2, 9) &&
713
            GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
714
                          "yyyy", buf3, 5)) {
715
          os << "%%CreationDate: " << buf1 << ' '
716
             << buf2 << ' ' << buf3 << std::endl;
717
        }
718
#endif
689
      os << bits::getWinFormattedDate();
719 690
#endif
720 691
    }
692
    os << std::endl;
721 693

	
722 694
    if (_autoArcWidthScale) {
723 695
      double max_w=0;
724 696
      for(ArcIt e(g);e!=INVALID;++e)
725 697
        max_w=std::max(double(_arcWidths[e]),max_w);
726 698
      if(max_w>EPSILON) {
727 699
        _arcWidthScale/=max_w;
728 700
      }
729 701
    }
730 702

	
731 703
    if (_autoNodeScale) {
732 704
      double max_s=0;
733 705
      for(NodeIt n(g);n!=INVALID;++n)
734 706
        max_s=std::max(double(_nodeSizes[n]),max_s);
735 707
      if(max_s>EPSILON) {
736 708
        _nodeScale/=max_s;
737 709
      }
738 710
    }
739 711

	
740 712
    double diag_len = 1;
741 713
    if(!(_absoluteNodeSizes&&_absoluteArcWidths)) {
742 714
      dim2::Box<double> bb;
743 715
      for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
744 716
      if (bb.empty()) {
Show white space 48 line context
... ...
@@ -56,49 +56,49 @@
56 56
 *
57 57
 * Any feedback is very welcome.
58 58
 * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
59 59
 * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
60 60
 */
61 61

	
62 62
#ifndef LEMON_RANDOM_H
63 63
#define LEMON_RANDOM_H
64 64

	
65 65
#include <algorithm>
66 66
#include <iterator>
67 67
#include <vector>
68 68
#include <limits>
69 69
#include <fstream>
70 70

	
71 71
#include <lemon/math.h>
72 72
#include <lemon/dim2.h>
73 73

	
74 74
#ifndef WIN32
75 75
#include <sys/time.h>
76 76
#include <ctime>
77 77
#include <sys/types.h>
78 78
#include <unistd.h>
79 79
#else
80
#include <windows.h>
80
#include <lemon/bits/windows.h>
81 81
#endif
82 82

	
83 83
///\ingroup misc
84 84
///\file
85 85
///\brief Mersenne Twister random number generator
86 86

	
87 87
namespace lemon {
88 88

	
89 89
  namespace _random_bits {
90 90

	
91 91
    template <typename _Word, int _bits = std::numeric_limits<_Word>::digits>
92 92
    struct RandomTraits {};
93 93

	
94 94
    template <typename _Word>
95 95
    struct RandomTraits<_Word, 32> {
96 96

	
97 97
      typedef _Word Word;
98 98
      static const int bits = 32;
99 99

	
100 100
      static const int length = 624;
101 101
      static const int shift = 397;
102 102

	
103 103
      static const Word mul = 0x6c078965u;
104 104
      static const Word arrayInit = 0x012BD6AAu;
... ...
@@ -641,51 +641,49 @@
641 641
    bool seedFromFile(const std::string& file = "", int offset = 0)
642 642
#endif
643 643
    {
644 644
      std::ifstream rs(file.c_str());
645 645
      const int size = 4;
646 646
      Word buf[size];
647 647
      if (offset != 0 && !rs.seekg(offset)) return false;
648 648
      if (!rs.read(reinterpret_cast<char*>(buf), sizeof(buf))) return false;
649 649
      seed(buf, buf + size);
650 650
      return true;
651 651
    }
652 652

	
653 653
    /// \brief Seding from process id and time
654 654
    ///
655 655
    /// Seding from process id and time. This function uses the
656 656
    /// current process id and the current time for initialize the
657 657
    /// random sequence.
658 658
    /// \return Currently always true.
659 659
    bool seedFromTime() {
660 660
#ifndef WIN32
661 661
      timeval tv;
662 662
      gettimeofday(&tv, 0);
663 663
      seed(getpid() + tv.tv_sec + tv.tv_usec);
664 664
#else
665
      FILETIME time;
666
      GetSystemTimeAsFileTime(&time);
667
      seed(GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime);
665
      seed(bits::getWinRndSeed());
668 666
#endif
669 667
      return true;
670 668
    }
671 669

	
672 670
    /// @}
673 671

	
674 672
    ///\name Uniform distributions
675 673
    ///
676 674
    /// @{
677 675

	
678 676
    /// \brief Returns a random real number from the range [0, 1)
679 677
    ///
680 678
    /// It returns a random real number from the range [0, 1). The
681 679
    /// default Number type is \c double.
682 680
    template <typename Number>
683 681
    Number real() {
684 682
      return _random_bits::RealConversion<Number, Word>::convert(core);
685 683
    }
686 684

	
687 685
    double real() {
688 686
      return real<double>();
689 687
    }
690 688

	
691 689
    /// \brief Returns a random real number from the range [0, 1)
Show white space 48 line context
... ...
@@ -3,56 +3,49 @@
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_TIME_MEASURE_H
20 20
#define LEMON_TIME_MEASURE_H
21 21

	
22 22
///\ingroup timecount
23 23
///\file
24 24
///\brief Tools for measuring cpu usage
25 25

	
26 26
#ifdef WIN32
27
#ifndef WIN32_LEAN_AND_MEAN
28
#define WIN32_LEAN_AND_MEAN
29
#endif
30
#ifndef NOMINMAX
31
#define NOMINMAX
32
#endif
33
#include <windows.h>
34
#include <cmath>
27
#include <lemon/bits/windows.h>
35 28
#else
36 29
#include <unistd.h>
37 30
#include <sys/times.h>
38 31
#include <sys/time.h>
39 32
#endif
40 33

	
41 34
#include <string>
42 35
#include <fstream>
43 36
#include <iostream>
44 37

	
45 38
namespace lemon {
46 39

	
47 40
  /// \addtogroup timecount
48 41
  /// @{
49 42

	
50 43
  /// A class to store (cpu)time instances.
51 44

	
52 45
  /// This class stores five time values.
53 46
  /// - a real time
54 47
  /// - a user cpu time
55 48
  /// - a system cpu time
56 49
  /// - a user cpu time of children
57 50
  /// - a system cpu time of children
58 51
  ///
... ...
@@ -71,68 +64,49 @@
71 64
    double rtime;
72 65

	
73 66
    void _reset() {
74 67
      utime = stime = cutime = cstime = rtime = 0;
75 68
    }
76 69

	
77 70
  public:
78 71

	
79 72
    ///Read the current time values of the process
80 73
    void stamp()
81 74
    {
82 75
#ifndef WIN32
83 76
      timeval tv;
84 77
      gettimeofday(&tv, 0);
85 78
      rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
86 79

	
87 80
      tms ts;
88 81
      double tck=sysconf(_SC_CLK_TCK);
89 82
      times(&ts);
90 83
      utime=ts.tms_utime/tck;
91 84
      stime=ts.tms_stime/tck;
92 85
      cutime=ts.tms_cutime/tck;
93 86
      cstime=ts.tms_cstime/tck;
94 87
#else
95
      static const double ch = 4294967296.0e-7;
96
      static const double cl = 1.0e-7;
97

	
98
      FILETIME system;
99
      GetSystemTimeAsFileTime(&system);
100
      rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
101

	
102
      FILETIME create, exit, kernel, user;
103
      if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
104
        utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
105
        stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
106
        cutime = 0;
107
        cstime = 0;
108
      } else {
109
        rtime = 0;
110
        utime = 0;
111
        stime = 0;
112
        cutime = 0;
113
        cstime = 0;
114
      }
88
      bits::getWinProcTimes(rtime, utime, stime, cutime, cstime);
115 89
#endif
116 90
    }
117 91

	
118 92
    /// Constructor initializing with zero
119 93
    TimeStamp()
120 94
    { _reset(); }
121 95
    ///Constructor initializing with the current time values of the process
122 96
    TimeStamp(void *) { stamp();}
123 97

	
124 98
    ///Set every time value to zero
125 99
    TimeStamp &reset() {_reset();return *this;}
126 100

	
127 101
    ///\e
128 102
    TimeStamp &operator+=(const TimeStamp &b)
129 103
    {
130 104
      utime+=b.utime;
131 105
      stime+=b.stime;
132 106
      cutime+=b.cutime;
133 107
      cstime+=b.cstime;
134 108
      rtime+=b.rtime;
135 109
      return *this;
136 110
    }
137 111
    ///\e
138 112
    TimeStamp operator+(const TimeStamp &b) const
0 comments (0 inline)