viztracer 1.1.0__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of viztracer might be problematic. Click here for more details.

Files changed (109) hide show
  1. viztracer/__init__.py +19 -0
  2. viztracer/__main__.py +8 -0
  3. viztracer/attach.py +67 -0
  4. viztracer/attach_process/LICENSE +203 -0
  5. viztracer/attach_process/__init__.py +0 -0
  6. viztracer/attach_process/add_code_to_python_process.py +582 -0
  7. viztracer/attach_process/attach_x86.dll +0 -0
  8. viztracer/attach_process/inject_dll_amd64.exe +0 -0
  9. viztracer/attach_process/linux_and_mac/lldb_prepare.py +54 -0
  10. viztracer/attach_process/run_code_on_dllmain_amd64.dll +0 -0
  11. viztracer/attach_process/run_code_on_dllmain_x86.dll +0 -0
  12. viztracer/cellmagic.py +70 -0
  13. viztracer/code_monkey.py +353 -0
  14. viztracer/decorator.py +164 -0
  15. viztracer/event_base.py +81 -0
  16. viztracer/functree.py +135 -0
  17. viztracer/html/flamegraph.html +34 -0
  18. viztracer/html/trace_viewer_embedder.html +203 -0
  19. viztracer/html/trace_viewer_full.html +10207 -0
  20. viztracer/main.py +699 -0
  21. viztracer/modules/eventnode.c +172 -0
  22. viztracer/modules/eventnode.h +73 -0
  23. viztracer/modules/pythoncapi_compat.h +1726 -0
  24. viztracer/modules/quicktime.c +177 -0
  25. viztracer/modules/quicktime.h +104 -0
  26. viztracer/modules/snaptrace.c +2205 -0
  27. viztracer/modules/snaptrace.h +134 -0
  28. viztracer/modules/snaptrace_member.c +483 -0
  29. viztracer/modules/util.c +45 -0
  30. viztracer/modules/util.h +22 -0
  31. viztracer/modules/vcompressor/vc_dump.c +1131 -0
  32. viztracer/modules/vcompressor/vc_dump.h +49 -0
  33. viztracer/modules/vcompressor/vcompressor.c +396 -0
  34. viztracer/modules/vcompressor/vcompressor.h +15 -0
  35. viztracer/patch.py +307 -0
  36. viztracer/report_builder.py +311 -0
  37. viztracer/snaptrace.cp314-win_amd64.pyd +0 -0
  38. viztracer/snaptrace.pyi +77 -0
  39. viztracer/util.py +196 -0
  40. viztracer/vcompressor.cp314-win_amd64.pyd +0 -0
  41. viztracer/vcompressor.pyi +10 -0
  42. viztracer/viewer.py +528 -0
  43. viztracer/vizcounter.py +20 -0
  44. viztracer/vizevent.py +31 -0
  45. viztracer/vizlogging.py +20 -0
  46. viztracer/vizobject.py +28 -0
  47. viztracer/vizplugin.py +143 -0
  48. viztracer/viztracer.py +472 -0
  49. viztracer/web_dist/LICENSE +189 -0
  50. viztracer/web_dist/index.html +127 -0
  51. viztracer/web_dist/service_worker.js +279 -0
  52. viztracer/web_dist/trace_processor +300 -0
  53. viztracer/web_dist/v52.0-6b9586def/assets/MaterialSymbolsOutlined.woff2 +0 -0
  54. viztracer/web_dist/v52.0-6b9586def/assets/Roboto-100.woff2 +0 -0
  55. viztracer/web_dist/v52.0-6b9586def/assets/Roboto-300.woff2 +0 -0
  56. viztracer/web_dist/v52.0-6b9586def/assets/Roboto-400.woff2 +0 -0
  57. viztracer/web_dist/v52.0-6b9586def/assets/Roboto-500.woff2 +0 -0
  58. viztracer/web_dist/v52.0-6b9586def/assets/RobotoCondensed-Light.woff2 +0 -0
  59. viztracer/web_dist/v52.0-6b9586def/assets/RobotoCondensed-Regular.woff2 +0 -0
  60. viztracer/web_dist/v52.0-6b9586def/assets/RobotoMono-Regular.woff2 +0 -0
  61. viztracer/web_dist/v52.0-6b9586def/assets/brand.png +0 -0
  62. viztracer/web_dist/v52.0-6b9586def/assets/catapult_trace_viewer.html +3946 -0
  63. viztracer/web_dist/v52.0-6b9586def/assets/catapult_trace_viewer.js +7539 -0
  64. viztracer/web_dist/v52.0-6b9586def/assets/favicon.png +0 -0
  65. viztracer/web_dist/v52.0-6b9586def/assets/logo-128.png +0 -0
  66. viztracer/web_dist/v52.0-6b9586def/assets/logo-3d.png +0 -0
  67. viztracer/web_dist/v52.0-6b9586def/assets/rec_atrace.png +0 -0
  68. viztracer/web_dist/v52.0-6b9586def/assets/rec_battery_counters.png +0 -0
  69. viztracer/web_dist/v52.0-6b9586def/assets/rec_board_voltage.png +0 -0
  70. viztracer/web_dist/v52.0-6b9586def/assets/rec_cpu_coarse.png +0 -0
  71. viztracer/web_dist/v52.0-6b9586def/assets/rec_cpu_fine.png +0 -0
  72. viztracer/web_dist/v52.0-6b9586def/assets/rec_cpu_freq.png +0 -0
  73. viztracer/web_dist/v52.0-6b9586def/assets/rec_cpu_voltage.png +0 -0
  74. viztracer/web_dist/v52.0-6b9586def/assets/rec_frame_timeline.png +0 -0
  75. viztracer/web_dist/v52.0-6b9586def/assets/rec_ftrace.png +0 -0
  76. viztracer/web_dist/v52.0-6b9586def/assets/rec_gpu_mem_total.png +0 -0
  77. viztracer/web_dist/v52.0-6b9586def/assets/rec_java_heap_dump.png +0 -0
  78. viztracer/web_dist/v52.0-6b9586def/assets/rec_lmk.png +0 -0
  79. viztracer/web_dist/v52.0-6b9586def/assets/rec_logcat.png +0 -0
  80. viztracer/web_dist/v52.0-6b9586def/assets/rec_long_trace.png +0 -0
  81. viztracer/web_dist/v52.0-6b9586def/assets/rec_mem_hifreq.png +0 -0
  82. viztracer/web_dist/v52.0-6b9586def/assets/rec_meminfo.png +0 -0
  83. viztracer/web_dist/v52.0-6b9586def/assets/rec_native_heap_profiler.png +0 -0
  84. viztracer/web_dist/v52.0-6b9586def/assets/rec_one_shot.png +0 -0
  85. viztracer/web_dist/v52.0-6b9586def/assets/rec_profiling.png +0 -0
  86. viztracer/web_dist/v52.0-6b9586def/assets/rec_ps_stats.png +0 -0
  87. viztracer/web_dist/v52.0-6b9586def/assets/rec_ring_buf.png +0 -0
  88. viztracer/web_dist/v52.0-6b9586def/assets/rec_syscalls.png +0 -0
  89. viztracer/web_dist/v52.0-6b9586def/assets/rec_vmstat.png +0 -0
  90. viztracer/web_dist/v52.0-6b9586def/assets/scheduling_latency.png +0 -0
  91. viztracer/web_dist/v52.0-6b9586def/assets/vscode-icon.png +0 -0
  92. viztracer/web_dist/v52.0-6b9586def/engine_bundle.js +3 -0
  93. viztracer/web_dist/v52.0-6b9586def/frontend_bundle.js +5495 -0
  94. viztracer/web_dist/v52.0-6b9586def/index.html +127 -0
  95. viztracer/web_dist/v52.0-6b9586def/manifest.json +52 -0
  96. viztracer/web_dist/v52.0-6b9586def/perfetto.css +5737 -0
  97. viztracer/web_dist/v52.0-6b9586def/stdlib_docs.json +1 -0
  98. viztracer/web_dist/v52.0-6b9586def/trace_config_utils.wasm +0 -0
  99. viztracer/web_dist/v52.0-6b9586def/trace_processor.wasm +0 -0
  100. viztracer/web_dist/v52.0-6b9586def/trace_processor_memory64.wasm +0 -0
  101. viztracer/web_dist/v52.0-6b9586def/traceconv.wasm +0 -0
  102. viztracer/web_dist/v52.0-6b9586def/traceconv_bundle.js +2 -0
  103. viztracer-1.1.0.dist-info/METADATA +316 -0
  104. viztracer-1.1.0.dist-info/RECORD +109 -0
  105. viztracer-1.1.0.dist-info/WHEEL +5 -0
  106. viztracer-1.1.0.dist-info/entry_points.txt +3 -0
  107. viztracer-1.1.0.dist-info/licenses/LICENSE +222 -0
  108. viztracer-1.1.0.dist-info/licenses/NOTICE.txt +27 -0
  109. viztracer-1.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,177 @@
1
+ // Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ // For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt
3
+
4
+
5
+ #include <Python.h>
6
+ #include <stdio.h>
7
+ #include <stdint.h>
8
+ #include <stdlib.h>
9
+ #include <stdbool.h>
10
+ #include <time.h>
11
+
12
+ #include "quicktime.h"
13
+
14
+ #if _WIN32
15
+ #include <windows.h>
16
+ LARGE_INTEGER qpc_freq;
17
+ #elif defined(__APPLE__)
18
+ #include <mach/mach_time.h>
19
+ mach_timebase_info_data_t timebase_info;
20
+ #endif
21
+
22
+
23
+ #define CALIBRATE_SIZE 1000
24
+
25
+ double ts_to_ns_factor = 1.0;
26
+ int64_t system_base_time = 0;
27
+ int64_t system_base_ts = 0;
28
+ int64_t* start_ts = NULL;
29
+ int64_t* start_ns = NULL;
30
+ int64_t t0_ts = 0;
31
+ int64_t t0_ns = 0;
32
+ bool calibrated = false;
33
+
34
+ static int
35
+ compare_double(const void *a, const void *b)
36
+ {
37
+ return (*(double *)a - *(double *)b);
38
+ }
39
+
40
+ static int
41
+ compare_int64(const void *a, const void *b)
42
+ {
43
+ return (*(int64_t *)a - *(int64_t *)b);
44
+ }
45
+
46
+ static void
47
+ calibrate_quicktime()
48
+ {
49
+ int64_t end_ts[CALIBRATE_SIZE] = {0};
50
+ int64_t end_ns[CALIBRATE_SIZE] = {0};
51
+ double factors[CALIBRATE_SIZE] = {0};
52
+
53
+ for (int i = 0; i < CALIBRATE_SIZE; i++)
54
+ {
55
+ int64_t end_before = get_system_ts();
56
+ end_ns[i] = get_system_ns();
57
+ int64_t end_after = get_system_ts();
58
+ end_ts[i] = end_before + (end_after - end_before) / 2;
59
+ }
60
+
61
+ for (int i = 0; i < CALIBRATE_SIZE; i++)
62
+ {
63
+ factors[i] = (double)(end_ns[i] - start_ns[i]) / (end_ts[i] - start_ts[i]);
64
+ }
65
+
66
+ qsort(factors, CALIBRATE_SIZE, sizeof(double), compare_double);
67
+
68
+ ts_to_ns_factor = factors[CALIBRATE_SIZE / 2];
69
+ }
70
+
71
+ double
72
+ system_ts_to_us(int64_t ts)
73
+ {
74
+ if (!calibrated)
75
+ {
76
+ calibrate_quicktime();
77
+ calibrated = true;
78
+ }
79
+ return system_ts_to_ns(ts) / 1000.0;
80
+ }
81
+
82
+ int64_t
83
+ system_ts_to_ns(int64_t ts)
84
+ {
85
+ if (!calibrated)
86
+ {
87
+ calibrate_quicktime();
88
+ calibrated = true;
89
+ }
90
+ return t0_ns + (ts - t0_ts) * ts_to_ns_factor;
91
+ }
92
+
93
+ double
94
+ dur_ts_to_us(int64_t dur)
95
+ {
96
+ if (!calibrated)
97
+ {
98
+ calibrate_quicktime();
99
+ calibrated = true;
100
+ }
101
+ return (double)dur * ts_to_ns_factor / 1000;
102
+ }
103
+
104
+ int64_t
105
+ dur_ts_to_ns(int64_t dur)
106
+ {
107
+ if (!calibrated)
108
+ {
109
+ calibrate_quicktime();
110
+ calibrated = true;
111
+ }
112
+ return dur * ts_to_ns_factor;
113
+ }
114
+
115
+ void
116
+ quicktime_free()
117
+ {
118
+ free(start_ts);
119
+ free(start_ns);
120
+ }
121
+
122
+ void
123
+ quicktime_init()
124
+ {
125
+ #if _WIN32
126
+ QueryPerformanceFrequency(&qpc_freq);
127
+ #elif defined(__APPLE__)
128
+ mach_timebase_info(&timebase_info);
129
+ #endif
130
+
131
+ start_ts = (int64_t*)malloc(sizeof(int64_t) * CALIBRATE_SIZE);
132
+ start_ns = (int64_t*)malloc(sizeof(int64_t) * CALIBRATE_SIZE);
133
+
134
+ int64_t diff_ns[CALIBRATE_SIZE] = {0};
135
+
136
+ t0_ts = 0;
137
+ t0_ns = 0;
138
+
139
+ for (int i = 0; i < CALIBRATE_SIZE; i++)
140
+ {
141
+ int64_t start_before = get_system_ts();
142
+ start_ns[i] = get_system_ns();
143
+ int64_t start_after = get_system_ts();
144
+ start_ts[i] = start_before + (start_after - start_before) / 2;
145
+ }
146
+
147
+ // Do the expensive average calculation outside the measurement loop
148
+ int64_t ts_remainder = 0;
149
+ int64_t ns_remainder = 0;
150
+ for (int i = 0; i < CALIBRATE_SIZE; i++)
151
+ {
152
+ // Divide by CALIBRATE_SIZE at each step instead of accumulate-and-divide to avoid overflow
153
+ t0_ts += start_ts[i] / CALIBRATE_SIZE;
154
+ t0_ns += start_ns[i] / CALIBRATE_SIZE;
155
+
156
+ // Also accumulate the remainders, which are unlikely to overflow
157
+ ts_remainder += start_ts[i] % CALIBRATE_SIZE;
158
+ ns_remainder += start_ns[i] % CALIBRATE_SIZE;
159
+ }
160
+ // Then finally add the average remainder
161
+ t0_ts += ts_remainder / CALIBRATE_SIZE;
162
+ t0_ns += ns_remainder / CALIBRATE_SIZE;
163
+
164
+ // Now let's find the base time
165
+
166
+ for (int i = 0; i < CALIBRATE_SIZE; i++)
167
+ {
168
+ int64_t start_before = get_system_ns();
169
+ diff_ns[i] = get_system_epoch_ns();
170
+ int64_t start_after = get_system_ns();
171
+ diff_ns[i] -= start_before + (start_after - start_before) / 2;
172
+ }
173
+
174
+ qsort(diff_ns, CALIBRATE_SIZE, sizeof(int64_t), compare_int64);
175
+
176
+ system_base_time = diff_ns[CALIBRATE_SIZE / 2];
177
+ }
@@ -0,0 +1,104 @@
1
+ // Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ // For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt
3
+
4
+
5
+ #ifndef __SNAPTRACE_QUICKTIME_H__
6
+ #define __SNAPTRACE_QUICKTIME_H__
7
+
8
+ #include <Python.h>
9
+ #include <stdint.h>
10
+ #include <time.h>
11
+
12
+ #if _WIN32
13
+ #include <windows.h>
14
+ extern LARGE_INTEGER qpc_freq;
15
+ #elif defined(__APPLE__)
16
+ #include <mach/mach_time.h>
17
+ extern mach_timebase_info_data_t timebase_info;
18
+ #endif
19
+
20
+ #if defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
21
+ #define QUICKTIME_RDTSC
22
+ #if defined(_MSC_VER)
23
+ #include <intrin.h>
24
+ #elif defined(__clang__)
25
+ // `__rdtsc` is available by default.
26
+ // NB: This has to be first, because Clang will also define `__GNUC__`
27
+ #elif defined(__GNUC__)
28
+ #include <x86intrin.h>
29
+ #else
30
+ #undef QUICKTIME_RDTSC
31
+ #endif
32
+ #endif
33
+
34
+ extern double ts_to_ns_factor;
35
+ extern int64_t system_base_time;
36
+
37
+ void quicktime_init();
38
+ void quicktime_free();
39
+ double system_ts_to_us(int64_t ts);
40
+ int64_t system_ts_to_ns(int64_t ts);
41
+ double dur_ts_to_us(int64_t dur);
42
+ int64_t dur_ts_to_ns(int64_t dur);
43
+
44
+ inline int64_t
45
+ get_base_time_ns(void)
46
+ {
47
+ return system_base_time;
48
+ };
49
+
50
+ inline int64_t
51
+ get_system_ts(void)
52
+ {
53
+ #if defined(QUICKTIME_RDTSC)
54
+ return __rdtsc();
55
+ #else
56
+ #if _WIN32
57
+ LARGE_INTEGER counter = {0};
58
+ QueryPerformanceCounter(&counter);
59
+ return counter.QuadPart;
60
+ #elif defined(__APPLE__)
61
+ return mach_absolute_time();
62
+ #else
63
+ struct timespec t;
64
+ clock_gettime(CLOCK_MONOTONIC, &t);
65
+ return (int64_t)(t.tv_sec * 1e9 + t.tv_nsec);
66
+ #endif
67
+ #endif
68
+ }
69
+
70
+ inline int64_t
71
+ get_system_ns(void)
72
+ {
73
+ #if _WIN32
74
+ LARGE_INTEGER counter = {0};
75
+ QueryPerformanceCounter(&counter);
76
+ return counter.QuadPart * 1e9 / qpc_freq.QuadPart;
77
+ #elif defined(__APPLE__)
78
+ return mach_absolute_time() * timebase_info.numer / timebase_info.denom;
79
+ #else
80
+ struct timespec t;
81
+ clock_gettime(CLOCK_MONOTONIC, &t);
82
+ return (int64_t)(t.tv_sec * 1e9 + t.tv_nsec);
83
+ #endif
84
+ }
85
+
86
+
87
+ inline int64_t
88
+ get_system_epoch_ns(void)
89
+ {
90
+ #if _WIN32
91
+ FILETIME ft;
92
+ ULARGE_INTEGER ui;
93
+ GetSystemTimePreciseAsFileTime(&ft);
94
+ ui.LowPart = ft.dwLowDateTime;
95
+ ui.HighPart = ft.dwHighDateTime;
96
+ return (ui.QuadPart - 116444736000000000ULL) * 100;
97
+ #else
98
+ struct timespec t;
99
+ clock_gettime(CLOCK_REALTIME, &t);
100
+ return (int64_t)t.tv_sec * 1e9 + t.tv_nsec;
101
+ #endif
102
+ }
103
+
104
+ #endif