diff --git a/README.md b/README.md index baad208d..71aad9cc 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Please see https://pocketpy.dev for details and try the following resources. + [Live Python Demo](https://pocketpy.dev/static/web/): Run Python code in your browser + [Live C Examples](https://pocketpy.github.io/examples/): Explore C-APIs in your browser + [Godot Extension](https://github.com/pocketpy/godot-pocketpy): Use pocketpy in Godot Engine ++ [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy): Debug and profile pocketpy scripts in VSCode ++ [Flutter Plugin](https://pub.dev/packages/pocketpy): Use pocketpy in Flutter apps ## Supported Platforms diff --git a/docs/features/debugging.md b/docs/features/debugging.md index f7383a7a..d3069c26 100644 --- a/docs/features/debugging.md +++ b/docs/features/debugging.md @@ -1,24 +1,11 @@ --- icon: dot title: Debugging +order: 80 --- -!!! -This feature is not available in `v2.0` yet. -!!! +## VSCode Extension -You can invoke `breakpoint()` in your python code to start a PDB-like session. +You can install our VSCode extension to debug pocketpy scripts. -The following commands are supported: - -+ `h, help`: show this help message -+ `q, quit`: exit the debugger -+ `n, next`: execute next line -+ `s, step`: step into -+ `w, where`: show current stack frame -+ `c, continue`: continue execution -+ `a, args`: show local variables -+ `l, list`: show lines around current line -+ `ll, longlist`: show all lines -+ `p, print `: evaluate expression -+ `!, execute statement`: execute statement +https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy diff --git a/docs/features/profiling.md b/docs/features/profiling.md new file mode 100644 index 00000000..33da48fe --- /dev/null +++ b/docs/features/profiling.md @@ -0,0 +1,23 @@ +--- +icon: dot +title: Profiling +order: 79 +--- + +To profile your pocketpy scripts, you can run `main.exe` with `--profile` flag. + +For example, to profile `test/test_math.py`, run + +``` +main.exe --profile test/test_math.py +``` + +This will output a JSON report file named `profile_report.json` in the current directory, +which records the time spent for each line. To visualize the report, please install our VSCode extension. + +https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy + +With pocketpy VSCode extension, press `F1` and type `pocketpy: Load Line Profiler Report`, +select `profile_report.json` and you will see a nice visualization of the profiling result. + +![lp](../static/profiler_demo.png) diff --git a/docs/index.md b/docs/index.md index e112d063..5a342559 100644 --- a/docs/index.md +++ b/docs/index.md @@ -13,6 +13,7 @@ Developers are able to write Python bindings via C-API or pybind11 compatible in + [Live Python Demo](https://pocketpy.dev/static/web/): Run Python code in your browser + [Live C Examples](https://pocketpy.github.io/examples/): Explore C-APIs in your browser + [Godot Extension](https://github.com/pocketpy/godot-pocketpy): Use pocketpy in Godot Engine ++ [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy): Debug and profile pocketpy scripts in VSCode + [Flutter Plugin](https://pub.dev/packages/pocketpy): Use pocketpy in Flutter apps ## What it looks like diff --git a/docs/static/profiler_demo.png b/docs/static/profiler_demo.png new file mode 100644 index 00000000..3bb742ad Binary files /dev/null and b/docs/static/profiler_demo.png differ