MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

deps/v8/tools/profiling/linux-perf-d8.py:115–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114
115def main():
116 cleanup = []
117 try:
118 # ==========================================================================
119 (options, args) = parser.parse_args()
120 if options.freq and options.count:
121 parser.error("--freq and --count are mutually exclusive. "
122 "See `perf record --help' for more details.")
123
124 if len(args) == 0:
125 parser.error("No d8 binary provided")
126
127 raw_perf_args = []
128 d8_bin = None
129 while args:
130 additional_arg = args.pop(0)
131 maybe_d8_bin = Path(additional_arg).absolute()
132 if maybe_d8_bin.exists():
133 d8_bin = maybe_d8_bin
134 break
135 else:
136 raw_perf_args.append(additional_arg)
137
138 if not d8_bin:
139 parser.error(f"D8 '{d8_bin}' does not exist")
140
141 if options.perf_data_dir is None:
142 options.perf_data_dir = Path.cwd()
143 else:
144 options.perf_data_dir = Path(options.perf_data_dir).absolute()
145 options.perf_data_dir.mkdir(parents=True, exist_ok=True)
146 if not options.perf_data_dir.is_dir():
147 parser.error(f"--perf-data-dir={options.perf_data_dir} "
148 "is not an directory or does not exist.")
149
150 if options.timeout and options.timeout < 0:
151 parser.error("--timeout should be a positive number")
152
153 # ==========================================================================
154
155 cmd = [
156 str(d8_bin), "--perf-prof", "--perf-prof-path",
157 options.perf_data_dir.as_posix()
158 ]
159
160 if not options.no_interpreted_frames_native_stack:
161 cmd += ["--interpreted-frames-native-stack"]
162 if options.perf_prof_annotate_wasm:
163 cmd += ["--perf-prof-annotate-wasm"]
164
165 if options.scope_to_mark_measure:
166 tmp_fifo_dir = tempfile.mkdtemp()
167 cleanup.append(lambda: shutil.rmtree(tmp_fifo_dir))
168
169 perf_ctl_fifo_path = os.path.join(tmp_fifo_dir, "perf_ctl.fifo")
170 perf_ack_fifo_path = os.path.join(tmp_fifo_dir, "perf_ack.fifo")
171 os.mkfifo(perf_ctl_fifo_path)
172 os.mkfifo(perf_ack_fifo_path)

Callers 1

linux-perf-d8.pyFile · 0.70

Calls 15

strFunction · 0.85
popMethod · 0.80
mkdtempMethod · 0.80
nowMethod · 0.80
sleepMethod · 0.80
childrenMethod · 0.80
logFunction · 0.70
wait_for_process_timeoutFunction · 0.70
inject_v8_symbolsFunction · 0.70
openMethod · 0.65
closeMethod · 0.65
decodeMethod · 0.65

Tested by

no test coverage detected