From e68ab9683dd0348ee37df33131edef4127023a0c Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Tue, 3 Oct 2023 22:17:42 -0700 Subject: [PATCH] Remove vdb from the code base (#370) --- .coveragerc | 2 - README.md | 11 - docs/source/basic_usage.rst | 14 - docs/source/installation.rst | 3 +- docs/source/virtual_debug.rst | 87 ----- docs/source/viztracer.rst | 13 - pyproject.toml | 3 +- src/viztracer/__init__.py | 1 - src/viztracer/functree.py | 3 - src/viztracer/main.py | 3 - src/viztracer/modules/eventnode.h | 1 - src/viztracer/modules/snaptrace.c | 32 +- src/viztracer/modules/snaptrace.h | 1 - src/viztracer/prog_snapshot.py | 483 -------------------------- src/viztracer/simulator.py | 151 -------- src/viztracer/tracer.py | 17 +- src/viztracer/viztracer.py | 3 - tests/archived/_test_prog_snapshot.py | 113 ------ tests/archived/_test_simulator.py | 262 -------------- tests/test_cmdline.py | 8 - tests/test_invalid.py | 1 - tests/test_performance.py | 14 - tests/test_tracer.py | 17 - 23 files changed, 5 insertions(+), 1238 deletions(-) delete mode 100644 docs/source/virtual_debug.rst delete mode 100644 src/viztracer/prog_snapshot.py delete mode 100644 src/viztracer/simulator.py delete mode 100644 tests/archived/_test_prog_snapshot.py delete mode 100644 tests/archived/_test_simulator.py diff --git a/.coveragerc b/.coveragerc index d46487a3..89a58df4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,5 +3,3 @@ cover_pylib = True source = viztracer omit = */viztracer/attach_process/* - */viztracer/prog_snapshot.py - */viztracer/simulator.py diff --git a/README.md b/README.md index 953f350d..b5f1b4d8 100644 --- a/README.md +++ b/README.md @@ -248,17 +248,6 @@ Refer to [remote attach docs](https://viztracer.readthedocs.io/en/stable/remote_ VizTracer needs to dump the internal data to json format. It is recommended for the users to install ```orjson```, which is much faster than the builtin ```json``` library. VizTracer will try to import ```orjson``` and fall back to the builtin ```json``` library if ```orjson``` does not exist. -## Virtual Debug - -You can virtually debug your program with you saved json report. The interface is very similar to ```pdb```. Even better, you can **go back in time** -because VizTracer has all the info recorded for you. - -```sh -vdb -``` - -Refer to the [docs](https://viztracer.readthedocs.io/en/stable/virtual_debug.html) for detailed commands - ## Performance VizTracer will introduce 2x to 3x overhead in the worst case. The overhead is much better if there are less function calls or if filters are applied correctly. diff --git a/docs/source/basic_usage.rst b/docs/source/basic_usage.rst index fda4caf9..ca719982 100644 --- a/docs/source/basic_usage.rst +++ b/docs/source/basic_usage.rst @@ -241,20 +241,6 @@ this usage. viztracer --align_combine run1.json run2.json -o compare_report.json -Debug Your Saved Report ------------------------ - -VizTracer allows you to debug your json report just like pdb. You can understand how your program is executed by -interact with it. Even better, you can **go back in time** because you know what happened before. - -**This feature will be removed from 0.16.0** - -.. code-block:: - - vdb - -For detailed commands, please refer to :doc:`virtual_debug` - Compress Your Report -------------------- diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 008ac9af..bc45a9df 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -15,11 +15,10 @@ You can also download the source code and build it yourself. Even though VizTracer functions without any other packages, it is still recommended to install the following packages to have a better performance. * orjson: better json dump/load performance -* rich: better interactive shell for vdb .. code-block:: - pip install orjson rich + pip install orjson Or you can install *full* version of viztracer: diff --git a/docs/source/virtual_debug.rst b/docs/source/virtual_debug.rst deleted file mode 100644 index 29d890f7..00000000 --- a/docs/source/virtual_debug.rst +++ /dev/null @@ -1,87 +0,0 @@ -Virtual Debug -============= - -**This feature will be removed on 0.16.0** - -To use virtual debug, you need to trace your program with ``--vdb`` using ``viztracer`` - -.. code-block: - - viztracer --vdb -o result.json your_program.py - - use ``vdb`` with your json report - -.. code-block:: - - vdb - -You can use the following commands in the interactive shell: - -(They are very similar to pdb) - -.. py:attribute:: s - - single step to next function entry/exit - -.. py:attribute:: sb - - single step **back** to last function entry/exit - -.. py:attribute:: n - - go to next function entry/exit without entering other function - -.. py:attribute:: nb - - go to **last** function entry/exit without entering other function - -.. py:attribute:: r - - go forward and return to the caller function - -.. py:attribute:: rb - - go backward and return to the caller function - -.. py:attribute:: t [] - - if ```` is not specified, display current timestamp, otherwise - go to the time specified by ````. ```` has the unit of us. - -.. py:attribute:: tid [] - - if ```` is not specified, list the current thread ids in the current process, otherwise - go to the thread at the current timestamp - -.. py:attribute:: pid [] - - if ```` is not specified, list the current process ids, otherwise - go to the first spawned thread in the specified process at the current timestamp - -.. py:attribute:: w - - list the call stack with ``>`` showing the current frame - -.. py:attribute:: u - - go up a level to inspect the outer frame - -.. py:attribute:: d - - go down a level to inspect the inner frame - -.. py:attribute:: counter - - print the counter recorded at the current timestamp - -.. py:attribute:: object - - print the objects recorded at the current timestamp - -.. py:attribute:: a, arg, args - - print the function args logged in VizTracer - -.. py:attribute:: q, quit, exit - - exit the program diff --git a/docs/source/viztracer.rst b/docs/source/viztracer.rst index e135f85c..59bf9e59 100644 --- a/docs/source/viztracer.rst +++ b/docs/source/viztracer.rst @@ -14,7 +14,6 @@ VizTracer log_print=False,\ log_gc=False,\ log_async=False,\ - vdb=False,\ pid_suffix=False,\ register_global=True,\ min_duration=0,\ @@ -190,18 +189,6 @@ VizTracer viztracer --log_async - .. py:attribute:: vdb - :type: boolean - :value: False - - whether make viztracer instrument for vdb, which would affect the overhead and the file size a bit - - Setting it to ``True`` is equivalent to - - .. code-block:: - - viztracer --vdb - .. py:attribute:: register_global :type: boolean :value: True diff --git a/pyproject.toml b/pyproject.toml index 99f20089..d6dae6ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,12 +32,11 @@ HomePage = "https://github.com/gaogaotiantian/viztracer" Documentation = "https://viztracer.readthedocs.io" [project.optional-dependencies] -full = ["rich", "orjson"] +full = ["orjson"] [project.scripts] viztracer = "viztracer:main" vizviewer = "viztracer:viewer_main" -vdb = "viztracer:sim_main" [tool.setuptools.dynamic] version = {attr = "viztracer.__version__"} diff --git a/src/viztracer/__init__.py b/src/viztracer/__init__.py index d689ab44..165db4ce 100644 --- a/src/viztracer/__init__.py +++ b/src/viztracer/__init__.py @@ -7,7 +7,6 @@ from .cellmagic import load_ipython_extension from .decorator import ignore_function, log_sparse, trace_and_save from .main import main -from .simulator import main as sim_main from .viewer import viewer_main from .vizcounter import VizCounter from .vizlogging import VizLoggingHandler diff --git a/src/viztracer/functree.py b/src/viztracer/functree.py index 8688c79e..7386cd3d 100644 --- a/src/viztracer/functree.py +++ b/src/viztracer/functree.py @@ -13,7 +13,6 @@ class FuncTreeNode: def __init__(self, event: Optional[Dict[str, Any]] = None) -> None: self.filename: Optional[str] = None self.lineno: Optional[int] = None - self.caller_lineno: int = -1 self.is_python: Optional[bool] = False self.funcname: Optional[str] = None self.parent: Optional[FuncTreeNode] = None @@ -35,8 +34,6 @@ def __init__(self, event: Optional[Dict[str, Any]] = None) -> None: self.funcname = m.group(1) self.filename = m.group(2) self.lineno = int(m.group(3)) - if "caller_lineno" in self.event: - self.caller_lineno = self.event["caller_lineno"] def is_ancestor(self, other: "FuncTreeNode") -> bool: return self.start < other.start and self.end > other.end diff --git a/src/viztracer/main.py b/src/viztracer/main.py index ad54751d..b7691108 100644 --- a/src/viztracer/main.py +++ b/src/viztracer/main.py @@ -126,8 +126,6 @@ def create_parser(self) -> argparse.ArgumentParser: help="Process VizTracer specific comments") parser.add_argument("--minimize_memory", action="store_true", default=False, help="Use json.dump to dump chunks to file to save memory") - parser.add_argument("--vdb", action="store_true", default=False, - help="Instrument for vdb, will increase the overhead") parser.add_argument("--pid_suffix", action="store_true", default=False, help=("append pid to file name. " "This should be used when you try to trace multi process programs. " @@ -255,7 +253,6 @@ def parse(self, argv: List[str]) -> VizProcedureResult: "log_sparse": options.log_sparse, "log_async": options.log_async, "log_audit": options.log_audit, - "vdb": options.vdb, "pid_suffix": True, "file_info": False, "register_global": True, diff --git a/src/viztracer/modules/eventnode.h b/src/viztracer/modules/eventnode.h index 18530ded..df478b05 100644 --- a/src/viztracer/modules/eventnode.h +++ b/src/viztracer/modules/eventnode.h @@ -31,7 +31,6 @@ struct FEEData { }; }; int type; - int caller_lineno; double dur; PyObject* asyncio_task; }; diff --git a/src/viztracer/modules/snaptrace.c b/src/viztracer/modules/snaptrace.c index ed19bc3d..d3f9908a 100644 --- a/src/viztracer/modules/snaptrace.c +++ b/src/viztracer/modules/snaptrace.c @@ -438,11 +438,6 @@ snaptrace_tracefunc(PyObject* obj, PyFrameObject* frame, int what, PyObject* arg if (CHECK_FLAG(self->check_flags, SNAPTRACE_LOG_RETURN_VALUE)) { node->data.fee.retval = PyObject_Repr(arg); } - if (!CHECK_FLAG(self->check_flags, SNAPTRACE_NOVDB) && f_back) { - node->data.fee.caller_lineno = PyFrame_GetLineNumber(f_back); - } else { - node->data.fee.caller_lineno = -1; - } } else if (is_c) { PyCFunctionObject* cfunc = (PyCFunctionObject*) arg; node->data.fee.ml_name = cfunc->m_ml->ml_name; @@ -461,11 +456,6 @@ snaptrace_tracefunc(PyObject* obj, PyFrameObject* frame, int what, PyObject* arg node->data.fee.tp_name = NULL; } } - if (!CHECK_FLAG(self->check_flags, SNAPTRACE_NOVDB)) { - node->data.fee.caller_lineno = PyFrame_GetLineNumber(frame); - } else { - node->data.fee.caller_lineno = -1; - } } if (CHECK_FLAG(self->check_flags, SNAPTRACE_LOG_ASYNC)) { @@ -759,12 +749,6 @@ snaptrace_load(TracerObject* self, PyObject* args) PyDict_SetItemString(dict, "name", name); Py_DECREF(name); - if (node->data.fee.caller_lineno >= 0) { - PyObject* caller_lineno = PyLong_FromLong(node->data.fee.caller_lineno); - PyDict_SetItemString(dict, "caller_lineno", caller_lineno); - Py_DECREF(caller_lineno); - } - PyObject* arg_dict = NULL; if (node->data.fee.args) { arg_dict = node->data.fee.args; @@ -986,10 +970,6 @@ snaptrace_dump(TracerObject* self, PyObject* args) fprintfeename(fptr, node, sanitize_function_name); fputc('\"', fptr); - if (node->data.fee.caller_lineno >= 0) { - fprintf(fptr, ",\"caller_lineno\":%d", node->data.fee.caller_lineno); - } - PyObject* arg_dict = NULL; if (node->data.fee.args) { arg_dict = node->data.fee.args; @@ -1157,7 +1137,7 @@ snaptrace_config(TracerObject* self, PyObject* args, PyObject* kw) { static char* kwlist[] = {"verbose", "lib_file_path", "max_stack_depth", "include_files", "exclude_files", "ignore_c_function", "ignore_frozen", - "log_func_retval", "vdb", "log_func_args", "log_async", "trace_self", + "log_func_retval", "log_func_args", "log_async", "trace_self", "min_duration", NULL}; int kw_verbose = -1; @@ -1168,12 +1148,11 @@ snaptrace_config(TracerObject* self, PyObject* args, PyObject* kw) int kw_ignore_c_function = -1; int kw_ignore_frozen = -1; int kw_log_func_retval = -1; - int kw_vdb = -1; int kw_log_func_args = -1; int kw_log_async = -1; int kw_trace_self = -1; double kw_min_duration = 0; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|isiOOpppppppd", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kw, "|isiOOppppppd", kwlist, &kw_verbose, &kw_lib_file_path, &kw_max_stack_depth, @@ -1182,7 +1161,6 @@ snaptrace_config(TracerObject* self, PyObject* args, PyObject* kw) &kw_ignore_c_function, &kw_ignore_frozen, &kw_log_func_retval, - &kw_vdb, &kw_log_func_args, &kw_log_async, &kw_trace_self, @@ -1228,12 +1206,6 @@ snaptrace_config(TracerObject* self, PyObject* args, PyObject* kw) UNSET_FLAG(self->check_flags, SNAPTRACE_LOG_RETURN_VALUE); } - if (kw_vdb == 0) { - SET_FLAG(self->check_flags, SNAPTRACE_NOVDB); - } else if (kw_vdb == 1) { - UNSET_FLAG(self->check_flags, SNAPTRACE_NOVDB); - } - if (kw_log_func_args == 1) { SET_FLAG(self->check_flags, SNAPTRACE_LOG_FUNCTION_ARGS); } else if (kw_log_func_args == 0) { diff --git a/src/viztracer/modules/snaptrace.h b/src/viztracer/modules/snaptrace.h index 9a263fc2..0e011263 100644 --- a/src/viztracer/modules/snaptrace.h +++ b/src/viztracer/modules/snaptrace.h @@ -17,7 +17,6 @@ #define SNAPTRACE_EXCLUDE_FILES (1 << 2) #define SNAPTRACE_IGNORE_C_FUNCTION (1 << 3) #define SNAPTRACE_LOG_RETURN_VALUE (1 << 4) -#define SNAPTRACE_NOVDB (1 << 5) #define SNAPTRACE_LOG_FUNCTION_ARGS (1 << 6) #define SNAPTRACE_IGNORE_FROZEN (1 << 7) #define SNAPTRACE_LOG_ASYNC (1 << 8) diff --git a/src/viztracer/prog_snapshot.py b/src/viztracer/prog_snapshot.py deleted file mode 100644 index 1ac4f767..00000000 --- a/src/viztracer/prog_snapshot.py +++ /dev/null @@ -1,483 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt - -# This file is deprecated, do not use it anymore - -try: - import orjson as json # type: ignore -except ImportError: - import json # type: ignore -import bisect -import os - -from . import __version__ -from .functree import FuncTree -from .util import color_print - - -class Frame: - def __init__(self, parent, node): - self.parent = parent - self.node = node - self.curr_children_idx = 0 - self.next = None - self.code_string = None - if parent: - parent.next = self - - @property - def curr_children_idx(self): - return self.__curr_children_idx - - @curr_children_idx.setter - def curr_children_idx(self, idx): - self.code_string = None - self.__curr_children_idx = idx - - def show(self, p): - if self.code_string: - p(self.code_string) - return - - node = self.node - firstlineno = node.lineno - if node.filename: - if not os.path.exists(node.filename): - p("> Not able to locate the source") - return - - with open(node.filename, encoding="utf-8") as f: - lst = f.readlines() - - start = firstlineno - 1 - line = lst[start] - stripped_line = line.lstrip() - code_indent = len(line) - len(stripped_line) - - if node.funcname != "": - end = firstlineno - indented = False - while end < len(lst): - line = lst[end] - stripped_line = line.lstrip() - indent = len(line) - len(stripped_line) - if indent > code_indent: - indented = True - elif indented: - if len(stripped_line) > 0 and \ - not stripped_line.startswith("#"): - break - end += 1 - - # clear the ending spaces - while lst[end - 1].strip() == "": - end -= 1 - else: - end = len(lst) - - if self.curr_children_idx >= len(self.node.children): - currline = end - else: - currline = self.node.children[self.curr_children_idx].caller_lineno - 1 - - for idx in range(start, end): - if len(lst[idx].strip()) > 0: - if idx == currline: - lst[idx] = "> " + lst[idx] - else: - lst[idx] = " " + lst[idx] - - if currline == end: - self.code_string = "".join(lst[start:end] + ["> \n"]) - else: - self.code_string = "".join(lst[start:end] + [" \n"]) - else: - self.code_string = "> " + self.node.fullname - p(self.code_string) - - -class CounterEvents: - def __init__(self): - self._events = [] - - def add_event(self, event): - # The events have to be added in order - if self._events: - args = self._events[-1]["args"].copy() - else: - args = {} - args.update(event["args"]) - self._events.append({ - "ts": event["ts"], - "args": args, - }) - - def normalize(self, first_ts): - for event in self._events: - event["ts"] -= first_ts - - def get_args(self, ts): - ts_lst = [event["ts"] for event in self._events] - idx = bisect.bisect(ts_lst, ts) - if idx == 0: - return {} - else: - return self._events[idx - 1]["args"] - - -class ObjectEvents: - def __init__(self): - self._objects = {} - - def add_event(self, event): - if event["id"] not in self._objects: - entry = { - "id": event["id"], - "name": event["name"], - "snapshots": [], - } - self._objects[event["id"]] = entry - - entry = self._objects[event["id"]] - - if event["ph"] in ["N", "D"]: - entry["snapshots"].append({ - "ts": event["ts"], - "args": None, - }) - elif event["ph"] == "O": - entry["snapshots"].append({ - "ts": event["ts"], - "args": event["args"]["snapshot"], - }) - else: # pragma: no cover - raise ValueError("Unexpected type for object event") - - def normalize(self, first_ts): - for entry in self._objects.values(): - for snapshot in entry["snapshots"]: - snapshot["ts"] -= first_ts - - def get_args(self, ts): - ret = {} - for entry in self._objects.values(): - ts_lst = [snapshot["ts"] for snapshot in entry["snapshots"]] - idx = bisect.bisect(ts_lst, ts) - if idx != 0: - snapshot = entry["snapshots"][idx - 1] - if snapshot["args"] is not None: - ret[entry["name"]] = snapshot["args"] - return ret - - -class ProgSnapshot: - compatible_version = "0.9.5" - - def __init__(self, json_string=None, p=print): - self.func_trees = {} - self.curr_node = None - self.curr_frame = None - self.first_tree = None - self.curr_tree = None - self.counter_events = CounterEvents() - self.object_events = ObjectEvents() - if json_string: - if not self.load(json_string): - self.valid = False - return - self.p = p - self.valid = True - - def load(self, json_string): - self.func_trees = {} - raw_data = json.loads(json_string) - if "viztracer_metadata" not in raw_data.keys(): - color_print("FAIL", "Error, json file version too old.") - return False - else: - if not self.check_version(raw_data["viztracer_metadata"]["version"]): - return False - trace_events = raw_data["traceEvents"] - for event in trace_events: - self.load_event(event) - self.first_tree = min(list(self.get_trees()), key=lambda x: x.first_ts()) - first_ts = self.first_tree.first_ts() - self.curr_tree = self.first_tree - self.curr_frame = Frame(None, self.first_tree.first_node()) - for tree in self.get_trees(): - tree.normalize(first_ts) - self.counter_events.normalize(first_ts) - self.object_events.normalize(first_ts) - return True - - def load_event(self, event): - # event is a chrome trace format event object - try: - ph = event["ph"] - pid = event["pid"] - tid = event["tid"] - except Exception: - raise ValueError("Error when loading event data: {}", event) - - if ph == "X": - if pid not in self.func_trees: - self.func_trees[pid] = {} - if tid not in self.func_trees[pid]: - self.func_trees[pid][tid] = FuncTree(pid, tid) - - self.func_trees[pid][tid].add_event(event) - elif ph == "C": - self.counter_events.add_event(event) - elif ph in ["N", "D", "O"]: - self.object_events.add_event(event) - elif ph == "M": - return - else: - print(f"Unsupported event type: {ph}") - return - - def check_version(self, version): - def get_version_tuple(v): - return tuple(int(elem) for elem in v.split(".")) - if get_version_tuple(version) < get_version_tuple(self.compatible_version): - color_print("FAIL", "Error, json file version too old.") - return False - elif get_version_tuple(version) > get_version_tuple(__version__): - color_print("WARNING", "Warning, json file version is newer than vdb! Not sure if it's compatible") - return True - - def get_trees(self): - for pid in self.func_trees: - for tid in self.func_trees[pid]: - yield self.func_trees[pid][tid] - return - - def show(self): - self.curr_frame.show(self.p) - - def up(self): - # Inspect previous frame - if not self.curr_frame.parent: - return False, "No outer frame anymore" - self.curr_frame = self.curr_frame.parent - return True, None - - def down(self): - if not self.curr_frame.next: - return False, "Already at current frame" - self.curr_frame = self.curr_frame.next - return True, None - - def _goto_inner_frame(self): - while self.curr_frame.next: - self.curr_frame = self.curr_frame.next - - def step(self): - self._goto_inner_frame() - curr_frame = self.curr_frame - if curr_frame.curr_children_idx < len(curr_frame.node.children): - child = curr_frame.node.children[curr_frame.curr_children_idx] - new_frame = Frame(curr_frame, child) - self.curr_frame = new_frame - else: - # go out of the function - success, _ = self.func_return() - if not success: - return False, "at the end of the trace" - return True, None - - def step_back(self): - self._goto_inner_frame() - curr_frame = self.curr_frame - if curr_frame.curr_children_idx > 0: - curr_frame.curr_children_idx -= 1 - child = curr_frame.node.children[curr_frame.curr_children_idx] - new_frame = Frame(curr_frame, child) - new_frame.curr_children_idx = len(new_frame.node.children) - self.curr_frame = new_frame - else: - # go out of the function - success, _ = self.func_return_back() - if not success: - return False, "at the beginning of the trace" - return True, None - - def next(self): - self._goto_inner_frame() - curr_frame = self.curr_frame - if curr_frame.curr_children_idx < len(curr_frame.node.children): - curr_frame.curr_children_idx += 1 - else: - # go out of the function - success, _ = self.func_return() - if not success: - return False, "at the end of the trace" - return True, None - - def next_back(self): - self._goto_inner_frame() - curr_frame = self.curr_frame - if curr_frame.curr_children_idx > 0: - curr_frame.curr_children_idx -= 1 - else: - # go out of the function - success, _ = self.func_return_back() - if not success: - return False, "at the beginning of the trace" - return True, None - - def func_return(self): - self._goto_inner_frame() - curr_frame = self.curr_frame - if not curr_frame.parent: - # Check if there's a sibling - node = curr_frame.node - idx = node.parent.children.index(node) - if idx < len(node.parent.children) - 1: - self.curr_frame = Frame(None, node.parent.children[idx + 1]) - return True, None - return False, "No callers available" - curr_frame = curr_frame.parent - curr_frame.curr_children_idx += 1 - curr_frame.next = None - self.curr_frame = curr_frame - - return True, None - - def func_return_back(self): - self._goto_inner_frame() - curr_frame = self.curr_frame - if not curr_frame.parent: - # Check if there's a sibling - node = curr_frame.node - idx = node.parent.children.index(node) - if idx > 0: - self.curr_frame = Frame(None, node.parent.children[idx - 1]) - return True, None - return False, "No callers available" - curr_frame = curr_frame.parent - curr_frame.next = None - self.curr_frame = curr_frame - - return True, None - - def where(self): - tmp_frame = self.curr_frame - while tmp_frame.parent: - tmp_frame = tmp_frame.parent - while True: - if tmp_frame == self.curr_frame: - self.p("> " + tmp_frame.node.fullname) - else: - self.p(" " + tmp_frame.node.fullname) - if tmp_frame.next: - tmp_frame = tmp_frame.next - else: - break - - return True, None - - def goto_timestamp(self, ts): - frame = Frame(None, self.curr_tree.node_by_timestamp(ts)) - while True: - if frame.node.children: - starts = [child.start for child in frame.node.children] - idx = bisect.bisect_left(starts, ts) - if idx == 0: - frame.curr_children_idx = 0 - break - else: - idx -= 1 - if frame.node.children[idx].end <= ts: - # here's what we need! - frame.curr_children_idx = idx + 1 - break - else: - new_frame = Frame(frame, frame.node.children[idx]) - frame = new_frame - else: - break - self.curr_frame = frame - - return True, None - - def get_timestamp(self): - tmp_frame = self.curr_frame - while tmp_frame.next: - tmp_frame = tmp_frame.next - if not tmp_frame.node.children: - return tmp_frame.node.start - if tmp_frame.curr_children_idx >= len(tmp_frame.node.children): - return tmp_frame.node.children[-1].end - else: - return tmp_frame.node.children[tmp_frame.curr_children_idx].start - - def print_timestamp(self): - self.p(str(self.get_timestamp())) - - return True, None - - def print_counter(self): - self.p(str(self.counter_events.get_args(self.get_timestamp()))) - - return True, None - - def print_object(self): - object_dict = self.object_events.get_args(self.get_timestamp()) - for k, v in object_dict.items(): - self.p(str(k) + ":") - self.p(str(v)) - - return True, None - - def list_tid(self): - curr_tree = self.curr_tree - forest = self.func_trees[curr_tree.pid] - for tid in forest: - if tid == curr_tree.tid: - self.p(f"> {tid}") - else: - self.p(f" {tid}") - - return True, None - - def list_pid(self): - curr_tree = self.curr_tree - for pid in self.func_trees: - if pid == curr_tree.pid: - self.p(f"> {pid}") - else: - self.p(f" {pid}") - - return True, None - - def goto_tid(self, tid): - assert (type(tid) is int) - forest = self.func_trees[self.curr_tree.pid] - if tid not in forest: - return False, "No such tid" - else: - ts = self.get_timestamp() - self.curr_tree = forest[tid] - self.goto_timestamp(ts) - - return True, None - - def goto_pid(self, pid): - assert (type(pid) is int) - if pid not in self.func_trees: - return False, "No such pid" - else: - ts = self.get_timestamp() - forest = self.func_trees[pid] - for tid in forest: - self.curr_tree = forest[tid] - break - self.goto_timestamp(ts) - - return True, None - - def print_args(self): - self.p(str(self.curr_frame.node.event.get("args", ""))) - - return True, None diff --git a/src/viztracer/simulator.py b/src/viztracer/simulator.py deleted file mode 100644 index f98687ea..00000000 --- a/src/viztracer/simulator.py +++ /dev/null @@ -1,151 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt - -# This file is deprecated, do not use it anymore - -try: - import readline # noqa: F401 -except ImportError: - pass -import argparse -import os -import sys - -from .prog_snapshot import ProgSnapshot - - -class Simulator: - def __init__(self, json_string, no_clear=False, extra_newline=False): - try: - from rich.console import Console # type: ignore - from rich.syntax import Syntax # type: ignore - self.console = Console() - - def p(s): - syntax = Syntax(s, "python", theme="monokai") - self.console.print(syntax, soft_wrap=True) - - self.print = p - except ImportError: - self.print = print - self.snapshot = ProgSnapshot(json_string, self.print) - if not self.snapshot.valid: - sys.exit(1) - self.no_clear = no_clear - self.extra_newline = extra_newline - - def start(self): - self.clear() - self.snapshot.show() - while True: - try: - cmd = input(">>> ") - if self.extra_newline: - print("") - self.parse_cmd(cmd) - except EOFError: - sys.exit(0) - - def clear(self): - if not self.no_clear: - os.system("cls" if os.name == "nt" else "clear") - - def parse_cmd(self, cmd): - args = cmd.split() - if not args: - return - success = False - if args[0] == "s": - success, err_msg = self.snapshot.step() - elif args[0] == "sb": - success, err_msg = self.snapshot.step_back() - elif args[0] == "n": - success, err_msg = self.snapshot.next() - elif args[0] == "nb": - success, err_msg = self.snapshot.next_back() - elif args[0] == "r": - success, err_msg = self.snapshot.func_return() - elif args[0] == "rb": - success, err_msg = self.snapshot.func_return_back() - elif args[0] == "t": - if len(args) == 1: - success, err_msg = self.snapshot.print_timestamp() - return - elif len(args) == 2: - success, err_msg = self.snapshot.goto_timestamp(float(args[1])) - else: - success, err_msg = False, "t takes 1 or no argument" - elif args[0] == "u": - success, err_msg = self.snapshot.up() - elif args[0] == "d": - success, err_msg = self.snapshot.down() - elif args[0] == "w": - success, err_msg = self.snapshot.where() - return - elif args[0] == "tid": - if len(args) == 1: - success, err_msg = self.snapshot.list_tid() - return - elif len(args) == 2: - try: - tid = int(args[1]) - success, err_msg = self.snapshot.goto_tid(tid) - except ValueError: - print("tid needs to be an integer") - return - else: - success, err_msg = False, "tid takes 1 or no argument" - elif args[0] == "pid": - if len(args) == 1: - success, err_msg = self.snapshot.list_pid() - return - elif len(args) == 2: - try: - pid = int(args[1]) - success, err_msg = self.snapshot.goto_pid(pid) - except ValueError: - print("tid needs to be an integer") - return - else: - success, err_msg = False, "pid takes 1 or no argument" - elif args[0] in ["arg", "args"]: - success, err_msg = self.snapshot.print_args() - return - elif args[0] == "counter": - success, err_msg = self.snapshot.print_counter() - return - elif args[0] == "object": - success, err_msg = self.snapshot.print_object() - return - elif args[0] in ["quit", "exit", "q"]: - sys.exit(0) - else: - print(f"Invalid command: {cmd}") - return - - if success: - self.clear() - self.snapshot.show() - else: - print(err_msg) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("file", nargs=1) - parser.add_argument("--no_clear", action="store_true", default=False) - parser.add_argument("--extra_newline", action="store_true", default=False) - - options = parser.parse_args(sys.argv[1:]) - - filename = options.file[0] - with open(filename, encoding="utf-8") as f: - s = f.read() - - sim = Simulator(s, no_clear=options.no_clear, extra_newline=options.extra_newline) - print("This feature is deprecated and will be removed on 0.16.0") - sim.start() - - -if __name__ == '__main__': - main() diff --git a/src/viztracer/tracer.py b/src/viztracer/tracer.py index b5a3d9d1..f72569b7 100644 --- a/src/viztracer/tracer.py +++ b/src/viztracer/tracer.py @@ -28,8 +28,7 @@ def __init__( log_gc: bool = False, log_async: bool = False, trace_self: bool = False, - min_duration: float = 0, - vdb: bool = False) -> None: + min_duration: float = 0) -> None: self.initialized = False self.enable = False self.parsed = False @@ -47,7 +46,6 @@ def __init__( self.log_func_args = log_func_args self.log_async = log_async self.min_duration = min_duration - self.vdb = vdb self.log_print = log_print self.log_gc = log_gc self.trace_self = trace_self @@ -193,18 +191,6 @@ def log_gc(self, log_gc: bool) -> None: else: raise ValueError(f"log_gc needs to be True or False, not {log_gc}") - @property - def vdb(self) -> bool: - return self.__vdb - - @vdb.setter - def vdb(self, vdb: bool) -> None: - if isinstance(vdb, bool): - self.__vdb = vdb - else: - raise ValueError(f"vdb needs to be True or False, not {vdb}") - self.config() - @property def verbose(self) -> int: return self.__verbose @@ -247,7 +233,6 @@ def config(self) -> None: "ignore_c_function": self.ignore_c_function, "ignore_frozen": self.ignore_frozen, "log_func_retval": self.log_func_retval, - "vdb": self.vdb, "log_func_args": self.log_func_args, "log_async": self.log_async, "trace_self": self.trace_self, diff --git a/src/viztracer/viztracer.py b/src/viztracer/viztracer.py index e104da7e..3dccb267 100644 --- a/src/viztracer/viztracer.py +++ b/src/viztracer/viztracer.py @@ -34,7 +34,6 @@ def __init__(self, log_sparse: bool = False, log_async: bool = False, log_audit: Optional[Sequence[str]] = None, - vdb: bool = False, pid_suffix: bool = False, file_info: bool = True, register_global: bool = True, @@ -55,7 +54,6 @@ def __init__(self, log_func_retval=log_func_retval, log_print=log_print, log_gc=log_gc, - vdb=vdb, log_func_args=log_func_args, log_async=log_async, trace_self=trace_self, @@ -116,7 +114,6 @@ def init_kwargs(self) -> Dict: "log_sparse": self.log_sparse, "log_async": self.log_async, "log_audit": self.log_audit, - "vdb": self.vdb, "pid_suffix": self.pid_suffix, "min_duration": self.min_duration, "dump_raw": self.dump_raw, diff --git a/tests/archived/_test_prog_snapshot.py b/tests/archived/_test_prog_snapshot.py deleted file mode 100644 index a1ee4b2e..00000000 --- a/tests/archived/_test_prog_snapshot.py +++ /dev/null @@ -1,113 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt - -import json - -from viztracer.prog_snapshot import ProgSnapshot - -from .base_tmpl import BaseTmpl - -test1_str = '{"traceEvents":[{"pid":7761,"tid":7761,"ts":23668655769.443,"dur":0.4,"name":"h (test.py:6)","caller_lineno":10,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655769.243,"dur":1.2,"name":"g (test.py:9)","caller_lineno":18,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655770.543,"dur":0.1,"name":"h (test.py:6)","caller_lineno":19,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655769.043,"dur":1.7,"name":"f (test.py:14)","caller_lineno":22,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655771.143,"dur":0.1,"name":"h (test.py:6)","caller_lineno":10,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655771.043,"dur":0.3,"name":"g (test.py:9)","caller_lineno":17,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655771.443,"dur":0.0,"name":"h (test.py:6)","caller_lineno":19,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655770.943,"dur":0.6,"name":"f (test.py:14)","caller_lineno":24,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655768.843,"dur":2.8,"name":"t (test.py:21)","caller_lineno":26,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655766.943,"dur":4.8,"name":" (test.py:2)","caller_lineno":147,"ph":"X","cat":"FEE"},{"pid":7761,"tid":7761,"ts":23668655766.343,"dur":5.8,"name":"builtins.exec","caller_lineno":147,"ph":"X","cat":"FEE"}],"displayTimeUnit":"ns","viztracer_metadata":{"version":"0.9.5"}}' # noqa: E501 - - -class TestSnapShot(BaseTmpl): - def test_basic(self): - snap = ProgSnapshot(test1_str) - tree_len = len(list(snap.get_trees())) - self.assertEqual(tree_len, 1) - tree = next(snap.get_trees()) - count = 0 - for _ in tree.inorder_traverse(): - count += 1 - self.assertEqual(count, 12) - - def test_step(self): - snap = ProgSnapshot(test1_str) - self.assertEqual(snap.curr_frame.node.fullname, "builtins.exec") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "t") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "f") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "g") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "h") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "g") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "f") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "h") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "f") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "t") - - def test_next(self): - snap = ProgSnapshot(test1_str) - self.assertEqual(snap.curr_frame.node.fullname, "builtins.exec") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "") - snap.step() - self.assertEqual(snap.curr_frame.node.funcname, "t") - snap.next() - self.assertEqual(snap.curr_frame.node.funcname, "t") - self.assertEqual(snap.curr_frame.curr_children_idx, 1) - - def test_random_entries(self): - import random - snap = ProgSnapshot(test1_str) - test_obj = json.loads(test1_str) - random.shuffle(test_obj["traceEvents"]) - snap2 = ProgSnapshot(json.dumps(test_obj)) - self.assertTrue(list(snap.get_trees())[0].is_same(list(snap2.get_trees())[0])) - - def test_version(self): - no_version_str = '{"traceEvents":[]}' - snap = ProgSnapshot(no_version_str) - self.assertFalse(snap.valid) - - low_version_str = '{"traceEvents":[], "viztracer_metadata":{"version":"0.0.1"}}' - snap = ProgSnapshot(low_version_str) - self.assertFalse(snap.valid) - - # Pure coverage - high_version_str = '{"traceEvents":[{"pid":7761,"tid":7761,"ts":23668655766.343,"dur":5.8,"name":"builtins.exec","caller_lineno":147,"ph":"X","cat":"FEE"}], "viztracer_metadata":{"version":"1000.0.1"}}' # noqa: E501 - snap = ProgSnapshot(high_version_str) - - def test_object(self): - data = '{"traceEvents": [{"pid":1,"tid":1,"ts":0.05,"dur":5.8,"name":"builtins.exec","caller_lineno":147,"ph":"X","cat":"FEE"}, {"ph": "N", "pid": 1, "tid": 1, "ts": 0.1, "id": 1000, "name": "a"}, {"ph": "D", "pid": 1, "tid": 1, "ts": 0.3, "id": 1000, "name": "a"}], "viztracer_metadata": {"version": "0.9.5"}}' # noqa: E501 - snap = ProgSnapshot(data) - self.assertEqual(len(snap.object_events._objects), 1) - - def test_invalid(self): - data = '{"traceEvents": [{"ph": "hello"}], "viztracer_metadata": {"version": "0.9.5"}}' - with self.assertRaises(ValueError): - _ = ProgSnapshot(data) - - data = '{"traceEvents": [{"ph": "hello", "pid": 1, "tid": 1}], "viztracer_metadata": {"version": "0.9.5"}}' - with self.assertRaises(ValueError): - _ = ProgSnapshot(data) - - def test_invalid_filename(self): - data = '{"traceEvents": [{"pid":7761,"tid":7761,"ts":23668655769.443,"dur":0.4,"name":"_handle_fromlist (:1017)","caller_lineno":10,"ph":"X","cat":"FEE"}], "viztracer_metadata": {"version": "0.9.5"}}' # noqa: E501 - prog = ProgSnapshot(data) - prog.show() - - def test_multiple_process(self): - data = '{"traceEvents": [{"pid":7762,"tid":7761,"ts":23668655766.343,"dur":5.8,"name":"builtins.exec","caller_lineno":147,"ph":"X","cat":"FEE"}, {"pid":7761,"tid":7761,"ts":23668655766.343,"dur":5.8,"name":"builtins.exec","caller_lineno":147,"ph":"X","cat":"FEE"}], "viztracer_metadata": {"version": "0.9.5"}}' # noqa: E501 - snap = ProgSnapshot(data) - self.assertEqual(len(list(snap.get_trees())), 2) - - # Coverage test - _ = snap.list_pid() - - def test_change_parent(self): - data = '{"traceEvents": [{"pid":7762,"tid":7761,"ts":0,"dur":100,"name":"grandpa","caller_lineno":147,"ph":"X","cat":"FEE"}, {"pid":7762,"tid":7761,"ts":50,"dur":10,"name":"grandson","caller_lineno":147,"ph":"X","cat":"FEE"}, {"pid":7762,"tid":7761,"ts":10,"dur":80,"name":"son","caller_lineno":147,"ph":"X","cat":"FEE"}], "viztracer_metadata": {"version": "0.9.5"}}' # noqa: E501 - snap = ProgSnapshot(data) - tree = next(snap.get_trees()) - for node in tree.inorder_traverse(): - if node.parent: - self.assertIn(node, node.parent.children) diff --git a/tests/archived/_test_simulator.py b/tests/archived/_test_simulator.py deleted file mode 100644 index b8a2585d..00000000 --- a/tests/archived/_test_simulator.py +++ /dev/null @@ -1,262 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/gaogaotiantian/viztracer/blob/master/NOTICE.txt - -import os -import subprocess -import sys - -from .base_tmpl import BaseTmpl -from .package_env import package_matrix -from .util import adapt_json_file, generate_json, get_json_file_path - - -adapt_json_file("vdb_basic.json") -vdb_basic = get_json_file_path("vdb_basic.json") -adapt_json_file("fib.json") -vdb_fib = get_json_file_path("fib.json") -adapt_json_file("old.json") -vdb_old = get_json_file_path("old.json") -generate_json("vdb_multithread.py") -vdb_multithread = get_json_file_path("vdb_multithread.json") - - -class SimInterface: - def __init__(self, json_path, vdb_cmd=["vdb", "--no_clear", "--extra_newline"], expect_fail=False): - commands = vdb_cmd + [json_path] - if os.getenv("COVERAGE_RUN"): - commands = ["coverage", "run", "--source", "viztracer", "--parallel-mode", - "-m", "viztracer.simulator"] + commands[1:] - self.sim_process = subprocess.Popen(commands, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) - if expect_fail: - self.sim_process.wait(timeout=3) - self.sim_process.stdout.close() - self.sim_process.stdin.close() - self.returncode = self.sim_process.returncode - return - self.sim_process.stdin.write('\n') - self.sim_process.stdin.flush() - - while True: - if self.sim_process.poll() is not None: - raise Exception("vdb unexpected closed") - line = self.sim_process.stdout.readline() - if line.startswith(">>>"): - break - - def command(self, cmd, block=True): - self.sim_process.stdin.write(cmd + '\n') - self.sim_process.stdin.flush() - self.sim_process.stdin.write('\n') - self.sim_process.stdin.flush() - if block: - ret = "" - data = False - while True: - if self.sim_process.poll() is not None: - raise Exception("vdb unexpected closed") - line = self.sim_process.stdout.readline() - if line.startswith(">>>"): - if data: - break - else: - data = True - ret += line - return ret - - def close(self): - if self.sim_process.poll() is None: - try: - self.command("q", False) - self.sim_process.wait(timeout=3) - self.sim_process.stdout.close() - self.sim_process.stdin.close() - if self.sim_process.returncode != 0: - raise Exception(f"error code {self.sim_process.returncode}") - except subprocess.TimeoutExpired: - self.sim_process.terminate() - - def __del__(self): - self.close() - - -class TestSimulator(BaseTmpl): - def get_func_stack(self, result): - line = result.replace("\r\n", "").replace("\n", "").replace("> ", " ") - return [s for s in line.split() if ':' not in s] - - def test_module_run(self): - sim = SimInterface(vdb_fib) - result = sim.command("s") - self.assertGreater(len(result), 10) - result = sim.command("s") - self.assertGreater(len(result), 2) - sim.close() - - def test_old(self): - sim = SimInterface(vdb_old, expect_fail=True) - self.assertNotEqual(sim.returncode, 0) - - def test_step(self): - sim = SimInterface(vdb_basic) - result1 = sim.command("s") - sim.command("sb") - result2 = sim.command("s") - self.assertEqual(result1, result2) - sim.close() - - def test_next(self): - sim = SimInterface(vdb_basic) - result1 = sim.command("n") - sim.command("nb") - result2 = sim.command("n") - self.assertEqual(result1, result2) - sim.close() - - def test_return(self): - sim = SimInterface(vdb_basic) - result1 = sim.command("n") - sim.command("sb") - result2 = sim.command("r") - self.assertEqual(result1, result2) - sim.command("s") - result3 = sim.command("rb") - self.assertEqual(result2, result3) - sim.close() - - def test_timestamp(self): - sim = SimInterface(vdb_basic) - result = sim.command("t -1") - result = sim.command("t") - self.assertAlmostEqual(float(result), 0.6, places=4) - sim.command("t 40") - result1 = sim.command("w") - self.assertEqual(self.get_func_stack(result1), ['t', 'f', 'g', 'h']) - sim.command("t 74.2") - result1 = sim.command("w") - self.assertEqual(self.get_func_stack(result1), ['t', 'f']) - sim.command("s") - sim.command("u") - result = sim.command("t") - self.assertAlmostEqual(float(result), 74.5, places=4) - sim.command("s") - result = sim.command("t") - self.assertAlmostEqual(float(result), 105.9, places=4) - result = sim.command("t 1 1") - self.assertIn("argument", result) - sim.close() - - @package_matrix(["~rich", "rich"]) - def test_tid_pid(self): - sim = SimInterface(vdb_basic) - result = sim.command("tid") - self.assertEqual(result.strip(), "> 3218") - sim.command("tid 3218") - result = sim.command("tid") - self.assertEqual(result.strip(), "> 3218") - result = sim.command("pid") - self.assertEqual(result.strip(), "> 3218") - sim.command("pid 3218") - result = sim.command("pid") - self.assertEqual(result.strip(), "> 3218") - result = sim.command("tid 1000") - self.assertTrue("def" not in result) - result = sim.command("pid 1000") - self.assertTrue("def" not in result) - result = sim.command("tid 10.5") - self.assertTrue("def" not in result) - result = sim.command("pid hello") - self.assertTrue("def" not in result) - result = sim.command("tid 1000 3218") - self.assertTrue("def" not in result) - result = sim.command("pid 3218 1000") - self.assertTrue("def" not in result) - sim.close() - - sim = SimInterface(vdb_multithread) - for _ in range(100): - sim.command("n") - result = sim.command("w") - for _ in range(101): - sim.command("nb") - result = sim.command("w") - result1 = sim.command("tid") - self.assertEqual(len(result1.strip().split()), 6) - sim.close() - - def test_counter(self): - sim = SimInterface(vdb_basic) - result = sim.command("counter") - self.assertEqual(result.strip(), "{}") - sim.command("t 75") - result = sim.command("counter") - self.assertEqual(result.strip(), "{'a': 7}") - sim.close() - - def test_object(self): - sim = SimInterface(vdb_basic) - sim.command("t 75") - result = sim.command("object") - self.assertEqual(result.split('\n')[1].strip(), "{'s': '5', 'b': 3}") - sim.close() - - def test_args(self): - # TODO: test real args - sim = SimInterface(vdb_basic) - sim.command("a") - sim.command("arg") - sim.command("args") - sim.close() - - @package_matrix(["~rich", "rich"]) - def test_up_down(self): - sim = SimInterface(vdb_basic) - result1 = sim.command("s") - result3 = sim.command("s") - result2 = sim.command("u") - result4 = sim.command("d") - self.assertEqual(result1, result2) - self.assertEqual(result3, result4) - # Make sure boundary won't break the code - for _ in range(5): - sim.command("u") - for _ in range(5): - sim.command("d") - sim.close() - - def test_edge(self): - # Behaviors on the beginning/end of the program - sim = SimInterface(vdb_basic) - result1 = sim.command("sb") - self.assertTrue("def" not in result1) - result1 = sim.command("nb") - self.assertTrue("def" not in result1) - result1 = sim.command("rb") - self.assertTrue("def" not in result1) - sim.command("n") - sim.command("n") - sim.command("n") - result1 = sim.command("s") - self.assertTrue("def" not in result1) - result1 = sim.command("n") - self.assertTrue("def" not in result1) - result1 = sim.command("r") - self.assertTrue("def" not in result1) - sim.close() - - def test_clear(self): - sim = SimInterface(vdb_basic, vdb_cmd=["vdb", "--extra_newline"]) - sim.command("s") - sim.close() - - def test_close(self): - if sys.platform in ["linux", "linux2", "darwin"]: - if os.getenv("COVERAGE_RUN"): - commands = f"coverage run --source viztracer --parallel-mode -m viztracer.simulator {vdb_basic} < /dev/null" - else: - commands = f"vdb {vdb_basic} < /dev/null" - - sim_process = subprocess.Popen([commands], - stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=True) - sim_process.wait() - self.assertEqual(sim_process.returncode, 0) diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index b421d943..6c571f9b 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -294,9 +294,6 @@ def test_ignore_c_function(self): def test_log_func_retval(self): self.template(["python", "-m", "viztracer", "--log_func_retval", "cmdline_test.py"], script=file_c_function) - def test_vdb(self): - self.template(["python", "-m", "viztracer", "--vdb", "cmdline_test.py"]) - def test_log_func_args(self): self.template(["python", "-m", "viztracer", "--log_func_args", "cmdline_test.py"]) @@ -358,11 +355,6 @@ def test_pid_suffix_and_output(self): self.assertFileExists(os.path.join("./suffix_tmp", f"test_{pid}.json")) self.cleanup(output_file="./suffix_tmp") - def test_path_finding(self): - if sys.platform in ["linux", "linux2", "darwin"]: - # path finding only works on Unix - self.template(["viztracer", "vdb"], success=False) - def test_module(self): self.template(["viztracer", "-m", "numbers"]) diff --git a/tests/test_invalid.py b/tests/test_invalid.py index c37b8934..86ef881b 100644 --- a/tests/test_invalid.py +++ b/tests/test_invalid.py @@ -20,7 +20,6 @@ def test_invalid_args(self): "log_func_retval": ["hello", 1, "True"], "log_gc": ["hello", 1, "True"], "log_func_args": ["hello", 1, "True"], - "vdb": ["hello", 1, "True"], "min_duration": ["0.1.0", "12", "3us"], "ignore_frozen": ["hello", 1, "True"], "log_async": ["hello", 1, "True"], diff --git a/tests/test_performance.py b/tests/test_performance.py index 506e456b..8262b298 100644 --- a/tests/test_performance.py +++ b/tests/test_performance.py @@ -76,20 +76,6 @@ def do_one_function(self, func): with bm_timer.time("baseline", "baseline", baseline=True): func() - # With viztracer + c tracer + vdb - tracer = VizTracer(verbose=0, vdb=True) - tracer.start() - with bm_timer.time("c+vdb", "c+vdb"): - func() - tracer.stop() - with bm_timer.time("c+vdb", "parse"): - tracer.parse() - with tempfile.TemporaryDirectory() as tmpdir: - ofile = os.path.join(tmpdir, "result.json") - with bm_timer.time("c+vdb", "save"): - tracer.save(output_file=ofile) - tracer.clear() - # With viztracer + c tracer tracer = VizTracer(verbose=0) tracer.start() diff --git a/tests/test_tracer.py b/tests/test_tracer.py index 033c5432..45a0591e 100644 --- a/tests/test_tracer.py +++ b/tests/test_tracer.py @@ -196,23 +196,6 @@ def test_log_func_retval(self): self.assertTrue("args" in events[0] and "return_value" in events[0]["args"]) - def test_novdb(self): - tracer = _VizTracer(vdb=True) - tracer.start() - fib(5) - tracer.stop() - tracer.parse() - events = [e for e in tracer.data["traceEvents"] if e["ph"] != "M"] - self.assertTrue("caller_lineno" in events[0]) - - tracer = _VizTracer(vdb=False) - tracer.start() - fib(5) - tracer.stop() - tracer.parse() - events = [e for e in tracer.data["traceEvents"] if e["ph"] != "M"] - self.assertFalse("caller_lineno" in events[0]) - def test_log_func_args(self): tracer = _VizTracer(log_func_args=True) tracer.start()