This file is indexed.

/usr/include/osl/misc/perfmon.h is in libosl-dev 0.6.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  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
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef MISC_PERFMON_H
#define MISC_PERFMON_H
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
#  define HAVE_TSC 1
#endif
#ifndef _MSC_VER
# include <sys/time.h>
# ifndef HAVE_TSC
#  include <sys/resource.h>
# endif
#endif
#include <iosfwd>
#include <string>
#include <cassert>
namespace osl
{
  namespace misc
  {
    class PerfMon
    {
#ifdef HAVE_TSC
      unsigned long long start_time;
#else
      rusage start_time;
#endif
    public:
      void restart()
      {
#ifdef HAVE_TSC
#  ifndef _MSC_VER
	unsigned int ax,dx;
	asm volatile("rdtsc\nmovl %%eax,%0\nmovl %%edx,%1":"=g"(ax),"=g"(dx): :"eax","edx");
	start_time =
	  (static_cast<unsigned long long>(dx)<<32)
	  + static_cast<unsigned long long>(ax);
#  else
	start_time = 0;
#  endif
#else
#ifdef NDEBUG
	getrusage(RUSAGE_SELF, &start_time);
#else
	int ret=getrusage(RUSAGE_SELF, &start_time);
	assert(ret==0);
#endif
#endif
      }
      PerfMon() {
	restart();
      }
      unsigned long long stop(){
#ifdef HAVE_TSC
#  ifndef _MSC_VER
	unsigned int ax,dx;
	asm volatile("rdtsc\nmovl %%eax,%0\nmovl %%edx,%1":"=g"(ax),"=g"(dx): :"eax","edx");
	const unsigned long long end_time
	  = ((static_cast<unsigned long long>(dx)<<32)
	     + static_cast<unsigned long long>(ax));
	return (end_time - PerfMon::start_time);
#  else
	return 0;
#  endif
#else
	rusage end_time;
#ifdef NDEBUG
	getrusage(RUSAGE_SELF,&end_time);
#else
	int ret=getrusage(RUSAGE_SELF,&end_time);
	assert(ret==0);
#endif
	return (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec)*1000000
	  +(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec);
#endif
      }
      void stop(const char *message,int loop){
	const unsigned long long cycles=stop();
	PerfMon::message(cycles, message, loop);
      }
      static void message(unsigned long long cycles,
			  const char *message,long long int loop);
    };
  
    class TSC
    {
      unsigned long long start_time;
      unsigned long long sum_time;
      long long int counter;
      std::string message;
    public:
      TSC(const char *m) :start_time(0ll),sum_time(0ll),counter(0ll),message(m) {}
      void start()
      {
#ifdef HAVE_TSC
#  ifndef _MSC_VER
	unsigned int ax,dx;
	asm volatile("rdtsc\nmovl %%eax,%0\nmovl %%edx,%1":"=g"(ax),"=g"(dx): :"eax","edx");
	start_time =
	  (static_cast<unsigned long long>(dx)<<32)
	  + static_cast<unsigned long long>(ax);
#  else
	start_time = 0;
#  endif
#endif
	counter++;
      }
      void stop(){
#ifdef HAVE_TSC
#  ifndef _MSC_VER
	unsigned int ax,dx;
	asm volatile("rdtsc\nmovl %%eax,%0\nmovl %%edx,%1":"=g"(ax),"=g"(dx): :"eax","edx");
	const unsigned long long end_time
	  = ((static_cast<unsigned long long>(dx)<<32)
	     + static_cast<unsigned long long>(ax));
	sum_time+=end_time - start_time;
#  else
	sum_time = 0;
#  endif
#endif
      }
      ~TSC()
      {
	PerfMon::message(sum_time,message.c_str(),counter);
      }
    };
    class Counter
    {
      unsigned long long int counter;
      std::string message;
    public:
      Counter(const char *m) :counter(0ll),message(m) {}
      Counter(std::string const& m) :counter(0ll),message(m) {}
      void count()
      {
	counter++;
      }
      ~Counter()
      {
	PerfMon::message(0ll,message.c_str(),counter);
      }
    };
    class CounterPair
    {
      unsigned long long int counter1;
      unsigned long long int counter2;
      std::string message;
    public:
      CounterPair(std::string const& m) :counter1(0ll),counter2(0ll),message(m) {}
      CounterPair(const char *file, const char *function, int line);
      void count1()
      {
	counter1++;
      }
      void count2()
      {
	counter2++;
      }
      ~CounterPair();
    };
#ifndef _MSC_VER
    class MeasureTimeLock
    {
      timeval start;
      std::ostream& os;
      char const* message;
    public:
      MeasureTimeLock (std::ostream& os, char const* message)
	: os (os), message (message)
      {
#ifndef NDEBUG
	int ret =
#endif
	  gettimeofday(&start, NULL);
	assert(ret == 0);
      }

      ~MeasureTimeLock();
    };
#endif
  } // namespace misc
} // namespace osl


#endif /* MISC_PERFMON_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End: