| 7 | namespace analysis { |
| 8 | |
| 9 | class Heatmap { |
| 10 | enum heatmapType { |
| 11 | WORKING_SET_REUSE_HEATMAP = 0, |
| 12 | SIZE_DISTRIBUTION_HEATMAP, |
| 13 | REUSE_DISTANCE_HEATMAP, |
| 14 | |
| 15 | INVALID_HEATMAP, |
| 16 | }; |
| 17 | |
| 18 | const std::string heatmap_type_names[INVALID_HEATMAP + 1] = { |
| 19 | "working_set_reuse_heatmap", |
| 20 | "size_distribution_heatmap", |
| 21 | "reuse_distance_heatmap", |
| 22 | "invalid_heatmap" |
| 23 | }; |
| 24 | |
| 25 | public: |
| 26 | double **heatval; |
| 27 | int32_t x_dim, y_dim; |
| 28 | bool initialized = false; |
| 29 | |
| 30 | Heatmap(int32_t x_dim, int32_t y_dim) { |
| 31 | set_dim(x_dim, y_dim); |
| 32 | } |
| 33 | |
| 34 | Heatmap() {}; |
| 35 | |
| 36 | void set_dim(int32_t x_dim_, int32_t y_dim_) { |
| 37 | if (initialized) { |
| 38 | WARNING("heatmap has been initialized\n"); |
| 39 | return; |
| 40 | } |
| 41 | x_dim = x_dim_; |
| 42 | y_dim = y_dim_; |
| 43 | heatval = new double *[x_dim_]; |
| 44 | for (int i = 0; i < x_dim; i++) { |
| 45 | heatval[i] = new double[y_dim_]; |
| 46 | for (int j = 0; j < y_dim; j++) { |
| 47 | heatval[i][j] = -1; |
| 48 | } |
| 49 | } |
| 50 | initialized = true; |
| 51 | } |
| 52 | |
| 53 | inline void set_val(int32_t x, int32_t y, double v) { |
| 54 | heatval[x][y] = v; |
| 55 | } |
| 56 | |
| 57 | void save_heatmap(std::string ofile_path) { |
| 58 | std::ofstream ofs(ofile_path, std::ios::out); |
| 59 | for (int j = 0; j < y_dim; j++) { |
| 60 | for (int i = 0; i < x_dim; i++) { |
| 61 | ofs << heatval[i][j] << " "; |
| 62 | } |
| 63 | ofs << std::endl; |
| 64 | } |
| 65 | ofs.close(); |
| 66 | } |
nothing calls this directly
no outgoing calls
no test coverage detected