additional fixes to checkstate
[deliverable/titan.core.git] / compiler2 / Stopwatch.cc
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 *
12 ******************************************************************************/
13 #include "Stopwatch.hh"
14 #include "error.h"
15 #include <stdio.h>
16
17 Stopwatch::Stopwatch(const char *name)
18 : tv_start()
19 , my_name(name)
20 {
21 gettimeofday(&tv_start, 0);
22 }
23
24 Stopwatch::~Stopwatch()
25 {
26 struct timeval tv_end;
27 gettimeofday(&tv_end, 0);
28
29 struct timeval tv_diff = {
30 tv_end.tv_sec - tv_start.tv_sec,
31 tv_end.tv_usec - tv_start.tv_usec
32 };
33 if (tv_diff.tv_usec < 0) {
34 --tv_diff.tv_sec;
35 tv_diff.tv_usec += 1000000;
36 }
37
38 NOTIFY("%s took %ld.%06ld sec", my_name,
39 (long)tv_diff.tv_sec, (long)tv_diff.tv_usec);
40 }
This page took 0.033878 seconds and 5 git commands to generate.