f12269633629a93b13f562cc3797c4351f537abc
[jump.git] / dol / src / dol / visitor / hds / lib / Performance_Extraction.h
1 #ifndef _PERFORMANCE_EXTRACTION_H
2 #define _PERFORMANCE_EXTRACTION_H
3
4 #include <sys/time.h>
5 #include <time.h>
6 #include "trace.h"
7
8 #define SYS_OVERHEAD 1400 //what should be exact vale
9 #define HOST_FREQUENCY 3 //Ghz
10
11 typedef struct COMP_ENTRY {
12     int start_line;
13     int end_line;
14     double total_computation_time;
15     int called_times;
16     COMP_ENTRY *next;
17 } COMP_ENTRY;
18
19 typedef struct CURRENT_TIME {
20     struct timespec ts;
21 }CURRENT_TIME;
22
23 extern  int get_current_time(CURRENT_TIME *current_time_ptr);
24 extern double sub_time(CURRENT_TIME *start_time_ptr, CURRENT_TIME *end_time_ptr);
25
26 class Process_Performance
27 {
28 private:
29     char _process_name[NAME_LENGTH];
30     COMP_ENTRY *_head;
31     COMP_ENTRY *_tail;
32
33 public:
34     Process_Performance(const char *process_name);
35     ~Process_Performance();
36
37     const char *get_name();
38     COMP_ENTRY * add_entry(int start_line, int end_line);
39     int set_entry(int start_line, int end_line, CURRENT_TIME *start_time_ptr,
40                   CURRENT_TIME *end_time_ptr);
41     COMP_ENTRY *get_entry(int start_line, int end_line);
42     COMP_ENTRY *get_head_entry();
43 };
44
45 class Performance_Extraction
46 {
47 private:
48     char _processor_type[NAME_LENGTH];
49     char _chr_file_name[NAME_LENGTH];
50     list<Process_Performance *> _list_process_performance;
51     list<Process_Performance *>::iterator _iter_process_performance;
52
53 public:
54     Performance_Extraction(const char *chr_file_name);
55     ~Performance_Extraction();
56
57     int add_computation_performance(const char *process_name, int start_line,
58                                     int end_line, CURRENT_TIME *start_time_ptr,
59                                     CURRENT_TIME *end_time_ptr);
60     Process_Performance *get_process_performance(const char *process_name);
61     int write_to_xml_file(const char *chr_file_name);
62     int add_to_xml_file(const char *chr_file_name);
63 };
64
65 extern Performance_Extraction performance_extraction;
66
67 #endif