source: src/Common/Stats/ResolveTime.cc@ be73f30

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since be73f30 was 57e0289, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Added stats option to print stats per expression in new-ast resolution

  • Property mode set to 100644
File size: 1.2 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// ResolveTime.cc --
8//
9// Author : Thierry Delisle
10// Created On : Wed Sep 16 15:45:51 2020
11// Last Modified By :
12// Last Modified On :
13// Update Count :
14//
15
16#include "ResolveTime.h"
17
18#include <fstream>
19#include <iomanip>
20
21#include "AST/Fwd.hpp"
22#include "AST/Expr.hpp"
23#include "AST/Print.hpp"
24#include "AST/Type.hpp"
25
26namespace Stats {
27 namespace ResolveTime {
28 static inline long long rdtscl(void) {
29 unsigned int lo, hi;
30 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
31 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
32 }
33
34 extern bool enabled;
35 bool started = false;
36 long long before;
37 std::ostream & out = std::cout;
38
39 void start( const ast::Expr * expr ) {
40 if(enabled) {
41 assert(!started);
42 started = true;
43
44 out << expr->location << " : ";
45
46 before = rdtscl();
47 }
48 }
49 void stop() {
50 if(enabled) {
51 assert(started);
52 auto after = rdtscl();
53 out << (after - before) << std::endl;
54
55 started = false;
56 }
57 }
58 };
59};
Note: See TracBrowser for help on using the repository browser.