| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 
 |  
#include "MTTime.h"
 
MTTime::MTTime()
       : origin_("")
  {
    gettimeofday(&begin_, &tz_);
  }
 
MTTime::MTTime(const std::string& origin)
    : origin_(origin)
  {
    gettimeofday(&begin_, &tz_);
  }
 
MTTime::~MTTime()
  {
    gettimeofday(&end_, &tz_);
    long time = (end_.tv_sec - begin_.tv_sec) * 
1000000L + (end_.tv_usec - begin_.tv_usec);
    if (!origin_.empty())
    cout << "[" << origin_ << "]";
    cout << "Temps dexécution : " << time << " us" << std::endl;
 
      }
#ifndef __MTime__
#define __MTime__
#include <iostream>
#include <sstream>
#include <ctime>
#include <sys/time.h>
 
class MTTime
{
  std::string origin_;
  struct timeval begin_, end_;
  struct timezone tz_;
 
public:
        MTTime();
        MTTime(const std::string& origin);
        ~MTTime();
};
#endif | 
Partager