codegreen 0.3.16__tar.gz → 0.4.1__tar.gz
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.
- {codegreen-0.3.16/codegreen.egg-info → codegreen-0.4.1}/PKG-INFO +33 -4
- {codegreen-0.3.16 → codegreen-0.4.1}/README.md +29 -1
- codegreen-0.4.1/benchmark/_workload_gpt2.py +31 -0
- codegreen-0.4.1/benchmark/_workload_gpt2_session.py +30 -0
- codegreen-0.4.1/benchmark/cg_modes_compare.py +109 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/__init__.py +19 -2
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analyzer/plot.py +68 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/cli/cli.py +1 -1
- codegreen-0.4.1/codegreen/instrumentation/language_runtimes/python/codegreen_runtime.py +836 -0
- {codegreen-0.3.16 → codegreen-0.4.1/codegreen.egg-info}/PKG-INFO +33 -4
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen.egg-info/SOURCES.txt +3 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen.egg-info/requires.txt +2 -1
- {codegreen-0.3.16 → codegreen-0.4.1}/pyproject.toml +4 -3
- {codegreen-0.3.16 → codegreen-0.4.1}/setup.py +46 -6
- codegreen-0.3.16/codegreen/instrumentation/language_runtimes/python/codegreen_runtime.py +0 -194
- {codegreen-0.3.16 → codegreen-0.4.1}/CMakeLists.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/LICENSE +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/MANIFEST.in +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/__main__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/compilers.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/config.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/harness.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/profilers.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/results.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/suites/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/suites/base.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/suites/benchmarksgame.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/suites/dacapo.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/suites/perfopt.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/suites/renaissance.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/validation/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/validation/analysis.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/validation/experiments.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/benchmark/validation/reporting.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/_ts_java.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/builder.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/callgraph.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/dataflow.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/energy_flow.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/features.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/pdg.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/types.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analysis/cfg/visualization.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/analyzer/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/cli/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/cli/entrypoint.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/config.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/ast_processor.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/bridge_analyze.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/bridge_instrument.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/config.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/configs/TEMPLATE.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/configs/c.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/configs/cpp.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/configs/java.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/configs/javascript.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/configs/python.json +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/engine.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/language_configs.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/language_engine.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/language_runtimes/c/codegreen_runtime.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/language_runtimes/cpp/codegreen/runtime.hpp +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/language_runtimes/java/codegreen/runtime/CodeGreenRuntime.java +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/instrumentation/language_runtimes/java/codegreen/runtime/CodeGreenStandaloneRuntime.java +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/utils/__init__.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/utils/binary.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen/utils/platform.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen.egg-info/dependency_links.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen.egg-info/entry_points.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen.egg-info/not-zip-safe +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/codegreen.egg-info/top_level.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/requirements.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/setup.cfg +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/tests/test_instrumentation.py +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/binarytrees/2.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/helloworld/1.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/knucleotide/1.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/mandelbrot/1-ffi.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/mandelbrot/1-mffi.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/nbody/2.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/nbody/5.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/nbody/8-i.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/nsieve/1.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/3.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/4.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/5-im.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/6-im.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/aligned_indent.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/array.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/comment.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/compound_lit.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/cond.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/enum.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/expr.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/func.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/if_else.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/issue-1568.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/issue-2086.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/issue-4079.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/issue-4117.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/issue-4525.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/label.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/loop.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/no_braces.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/preproc_cond.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/preproc_func.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/string.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/struct.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/switch.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/ternary.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/indent/c/unfinished_comment.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/nvim-treesitter/tests/query/highlights/c/enums-as-constants.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/crates/cli/src/templates/PARSER_NAME.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/crates/cli/src/templates/py-binding.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/crates/generate/src/templates/alloc.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/crates/generate/src/templates/array.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/crates/highlight/include/tree_sitter/highlight.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/crates/tags/include/tree_sitter/tags.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/CMakeLists.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/binding_web/lib/tree-sitter.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/include/tree_sitter/api.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/alloc.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/alloc.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/array.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/atomic.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/clock.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/error_costs.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/get_changed_ranges.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/get_changed_ranges.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/host.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/language.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/language.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/length.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/lexer.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/lexer.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/lib.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/node.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/parser.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/parser.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/point.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/portable/endian.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/query.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/reduce_action.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/reusable_node.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/stack.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/stack.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/subtree.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/subtree.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/tree.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/tree.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/tree_cursor.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/tree_cursor.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/ts_assert.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode/ptypes.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode/umachine.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode/urename.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode/utf.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode/utf16.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode/utf8.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/unicode.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/wasm/stdlib.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/wasm/wasm-stdlib.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/wasm_store.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/lib/src/wasm_store.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/depends_on_column/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/epsilon_external_extra_tokens/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/epsilon_external_tokens/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/external_tokens/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/external_unicode_column_alignment/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/get_col_eof/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/get_col_should_hang_not_crash/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/inverted_external_token/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter/test/fixtures/test_grammars/uses_current_column/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/CMakeLists.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/bindings/c/tree_sitter/tree-sitter-c.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/bindings/python/tree_sitter_c/binding.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/bindings/swift/TreeSitterC/c.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/examples/cluster.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/examples/malloc.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/examples/parser.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/src/parser.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/src/tree_sitter/parser.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/test/highlight/keywords.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-c/test/highlight/names.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/CMakeLists.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/bindings/c/tree-sitter-cpp.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/bindings/python/tree_sitter_cpp/binding.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/bindings/swift/TreeSitterCPP/cpp.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/examples/marker-index.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/src/parser.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/src/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-cpp/src/tree_sitter/parser.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/CMakeLists.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/bindings/c/tree-sitter-java.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/bindings/python/tree_sitter_java/binding.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/bindings/swift/TreeSitterJava/java.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/src/parser.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-java/src/tree_sitter/parser.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/CMakeLists.txt +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/bindings/c/tree-sitter-python.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/bindings/python/tree_sitter_python/binding.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/bindings/swift/TreeSitterPython/python.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/src/parser.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/src/scanner.c +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.16 → codegreen-0.4.1}/third_party/tree-sitter-python/src/tree_sitter/parser.h +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegreen
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Know the true energy cost of your code
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Know the true energy cost of your code
|
|
5
5
|
Author-email: Saurabhsingh Rajput <saurabh@dal.ca>
|
|
6
6
|
Maintainer-email: Saurabhsingh Rajput <saurabh@dal.ca>
|
|
7
7
|
License: Mozilla Public License Version 2.0
|
|
@@ -411,7 +411,8 @@ Requires-Dist: pydantic>=1.10.0
|
|
|
411
411
|
Requires-Dist: psutil>=5.9.0
|
|
412
412
|
Requires-Dist: packaging>=21.0
|
|
413
413
|
Requires-Dist: markdown-it-py<4.0.0,>=3.0.0
|
|
414
|
-
Requires-Dist: tree-sitter
|
|
414
|
+
Requires-Dist: tree-sitter<0.26,>=0.21
|
|
415
|
+
Requires-Dist: tree-sitter-language-pack<1.0,>=0.7
|
|
415
416
|
Provides-Extra: dev
|
|
416
417
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
417
418
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -487,7 +488,7 @@ sudo ./install.sh # or: sudo codegreen init-sensors
|
|
|
487
488
|
|
|
488
489
|
## Usage
|
|
489
490
|
|
|
490
|
-
### Measure energy of any command
|
|
491
|
+
### Measure energy of any command
|
|
491
492
|
|
|
492
493
|
```bash
|
|
493
494
|
codegreen run -- python script.py
|
|
@@ -508,6 +509,34 @@ codegreen measure python script.py -g fine --json
|
|
|
508
509
|
codegreen measure python script.py -g fine --export-plot energy.html
|
|
509
510
|
```
|
|
510
511
|
|
|
512
|
+
### Manual measurement from Python (Session API)
|
|
513
|
+
|
|
514
|
+
For span-based measurement of arbitrary code regions, import `codegreen.Session` directly — no CLI, no AST instrumentation:
|
|
515
|
+
|
|
516
|
+
```python
|
|
517
|
+
import codegreen
|
|
518
|
+
|
|
519
|
+
with codegreen.Session("training-run") as s:
|
|
520
|
+
with s.task("data_load"):
|
|
521
|
+
load_data()
|
|
522
|
+
with s.task("train"):
|
|
523
|
+
model.fit(...)
|
|
524
|
+
with s.task("eval"):
|
|
525
|
+
score = model.evaluate(...)
|
|
526
|
+
# writes codegreen_<pid>.json with per-task energy + per-domain breakdown
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
Time-series sampling for power-vs-time plots (area under curve = energy):
|
|
530
|
+
|
|
531
|
+
```python
|
|
532
|
+
with codegreen.Session("infer", record_time_series=True) as s:
|
|
533
|
+
with s.task("batch1"):
|
|
534
|
+
run_inference()
|
|
535
|
+
s.export_plot("infer.html") # interactive Plotly chart
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
The Session API uses the same NEMB backend as the CLI (RAPL/NVML/IOReport), supports nested + concurrent tasks, and degrades gracefully if the native library is unavailable. See [API → Python](docs/website/docs/api/python.md) for the full reference.
|
|
539
|
+
|
|
511
540
|
### Static analysis (no execution)
|
|
512
541
|
|
|
513
542
|
```bash
|
|
@@ -55,7 +55,7 @@ sudo ./install.sh # or: sudo codegreen init-sensors
|
|
|
55
55
|
|
|
56
56
|
## Usage
|
|
57
57
|
|
|
58
|
-
### Measure energy of any command
|
|
58
|
+
### Measure energy of any command
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
61
|
codegreen run -- python script.py
|
|
@@ -76,6 +76,34 @@ codegreen measure python script.py -g fine --json
|
|
|
76
76
|
codegreen measure python script.py -g fine --export-plot energy.html
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
### Manual measurement from Python (Session API)
|
|
80
|
+
|
|
81
|
+
For span-based measurement of arbitrary code regions, import `codegreen.Session` directly — no CLI, no AST instrumentation:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import codegreen
|
|
85
|
+
|
|
86
|
+
with codegreen.Session("training-run") as s:
|
|
87
|
+
with s.task("data_load"):
|
|
88
|
+
load_data()
|
|
89
|
+
with s.task("train"):
|
|
90
|
+
model.fit(...)
|
|
91
|
+
with s.task("eval"):
|
|
92
|
+
score = model.evaluate(...)
|
|
93
|
+
# writes codegreen_<pid>.json with per-task energy + per-domain breakdown
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Time-series sampling for power-vs-time plots (area under curve = energy):
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
with codegreen.Session("infer", record_time_series=True) as s:
|
|
100
|
+
with s.task("batch1"):
|
|
101
|
+
run_inference()
|
|
102
|
+
s.export_plot("infer.html") # interactive Plotly chart
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The Session API uses the same NEMB backend as the CLI (RAPL/NVML/IOReport), supports nested + concurrent tasks, and degrades gracefully if the native library is unavailable. See [API → Python](docs/website/docs/api/python.md) for the full reference.
|
|
106
|
+
|
|
79
107
|
### Static analysis (no execution)
|
|
80
108
|
|
|
81
109
|
```bash
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""GPT-2 generation workload. Same script is used unchanged across modes."""
|
|
2
|
+
import os, time
|
|
3
|
+
os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error")
|
|
4
|
+
|
|
5
|
+
import torch
|
|
6
|
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
|
7
|
+
|
|
8
|
+
PROMPTS = [
|
|
9
|
+
"Energy-aware computing is",
|
|
10
|
+
"The cheapest way to train a model is",
|
|
11
|
+
"Hardware energy counters report",
|
|
12
|
+
"Modern transformers can be optimized by",
|
|
13
|
+
] * 8 # 32 prompts -> dominates total runtime over import cost
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
18
|
+
tok = GPT2Tokenizer.from_pretrained("gpt2")
|
|
19
|
+
tok.pad_token = tok.eos_token
|
|
20
|
+
tok.padding_side = "left"
|
|
21
|
+
model = GPT2LMHeadModel.from_pretrained("gpt2").to(device).eval()
|
|
22
|
+
batch = tok(PROMPTS, padding=True, return_tensors="pt").to(device)
|
|
23
|
+
t0 = time.perf_counter()
|
|
24
|
+
with torch.no_grad():
|
|
25
|
+
out = model.generate(**batch, max_new_tokens=128, do_sample=False)
|
|
26
|
+
dt = time.perf_counter() - t0
|
|
27
|
+
print(f"workload done: device={device} prompts={len(PROMPTS)} gen_s={dt:.2f}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
main()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Same workload as cg_workload.py but bracketed under codegreen.Session.
|
|
2
|
+
Measures the same wall-clock span codegreen run measures."""
|
|
3
|
+
import os, time
|
|
4
|
+
os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error")
|
|
5
|
+
|
|
6
|
+
import codegreen
|
|
7
|
+
|
|
8
|
+
with codegreen.Session("whole-script", output_file=os.environ.get("CG_OUT", "/tmp/cg_session_run.json")) as s:
|
|
9
|
+
with s.task("everything"):
|
|
10
|
+
import torch
|
|
11
|
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
|
12
|
+
|
|
13
|
+
PROMPTS = [
|
|
14
|
+
"Energy-aware computing is",
|
|
15
|
+
"The cheapest way to train a model is",
|
|
16
|
+
"Hardware energy counters report",
|
|
17
|
+
"Modern transformers can be optimized by",
|
|
18
|
+
] * 8
|
|
19
|
+
|
|
20
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
21
|
+
tok = GPT2Tokenizer.from_pretrained("gpt2")
|
|
22
|
+
tok.pad_token = tok.eos_token
|
|
23
|
+
tok.padding_side = "left"
|
|
24
|
+
model = GPT2LMHeadModel.from_pretrained("gpt2").to(device).eval()
|
|
25
|
+
batch = tok(PROMPTS, padding=True, return_tensors="pt").to(device)
|
|
26
|
+
t0 = time.perf_counter()
|
|
27
|
+
with torch.no_grad():
|
|
28
|
+
out = model.generate(**batch, max_new_tokens=128, do_sample=False)
|
|
29
|
+
dt = time.perf_counter() - t0
|
|
30
|
+
print(f"workload done: device={device} prompts={len(PROMPTS)} gen_s={dt:.2f}")
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Run identical GPT-2 workload through CodeGreen access modes and compare totals.
|
|
2
|
+
|
|
3
|
+
Mode A: `codegreen run` -- whole-program energy via the CLI
|
|
4
|
+
Mode B: `codegreen.Session` (manual span around the entire script body)
|
|
5
|
+
|
|
6
|
+
Both bracket the same wall-clock span, so the readings should agree within
|
|
7
|
+
small noise (no instrumentation overhead from extra checkpoints).
|
|
8
|
+
|
|
9
|
+
A third reference is bare wall-clock (no codegreen) to check timing parity."""
|
|
10
|
+
import json, os, statistics, subprocess, sys, time
|
|
11
|
+
|
|
12
|
+
REPEAT = int(os.environ.get("CG_REPEAT", "3"))
|
|
13
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
14
|
+
WORKLOAD = os.path.join(HERE, "_workload_gpt2.py")
|
|
15
|
+
WORKLOAD_SESSION = os.path.join(HERE, "_workload_gpt2_session.py")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _parse_json_blob(stdout: str) -> dict:
|
|
19
|
+
"""codegreen --json prints multi-line JSON; find the outermost {...} block."""
|
|
20
|
+
s = stdout
|
|
21
|
+
start = s.find("{")
|
|
22
|
+
end = s.rfind("}")
|
|
23
|
+
if start < 0 or end < 0 or end <= start:
|
|
24
|
+
raise RuntimeError(f"no JSON block found in stdout (last 300 chars):\n{s[-300:]}")
|
|
25
|
+
return json.loads(s[start:end + 1])
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def mode_cli_run():
|
|
29
|
+
cmd = ["codegreen", "run", "python", WORKLOAD, "--repeat", "1", "--warmup", "0", "--json"]
|
|
30
|
+
res = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
|
|
31
|
+
if res.returncode != 0:
|
|
32
|
+
raise RuntimeError(f"codegreen run failed:\n{res.stderr[-400:]}")
|
|
33
|
+
d = _parse_json_blob(res.stdout)
|
|
34
|
+
e = d.get("energy_joules", {})
|
|
35
|
+
t = d.get("time_seconds", {})
|
|
36
|
+
energy = e.get("mean") if isinstance(e, dict) else e
|
|
37
|
+
secs = t.get("mean") if isinstance(t, dict) else t
|
|
38
|
+
return {"energy_j": energy, "power_w": d.get("power_watts"), "wall_s": secs,
|
|
39
|
+
"domains": d.get("domains") or {}}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def mode_session():
|
|
43
|
+
out = f"/tmp/_session_{os.getpid()}_{time.time()}.json"
|
|
44
|
+
env = dict(os.environ); env["CG_OUT"] = out
|
|
45
|
+
res = subprocess.run([sys.executable, WORKLOAD_SESSION], env=env, capture_output=True, text=True, timeout=600)
|
|
46
|
+
if res.returncode != 0:
|
|
47
|
+
raise RuntimeError(f"session script failed:\n{res.stderr[-400:]}")
|
|
48
|
+
rep = json.load(open(out))
|
|
49
|
+
task = rep["tasks"][0]
|
|
50
|
+
return {"energy_j": task["energy_j"], "power_w": task["avg_power_w"],
|
|
51
|
+
"wall_s": task["duration_s"], "domains": task["domains"]}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def mode_bare():
|
|
55
|
+
t0 = time.perf_counter()
|
|
56
|
+
res = subprocess.run([sys.executable, WORKLOAD], capture_output=True, text=True, timeout=600)
|
|
57
|
+
dt = time.perf_counter() - t0
|
|
58
|
+
if res.returncode != 0:
|
|
59
|
+
raise RuntimeError(f"bare run failed:\n{res.stderr[-400:]}")
|
|
60
|
+
return {"energy_j": None, "power_w": None, "wall_s": dt, "domains": {}}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def repeat_run(label, fn):
|
|
64
|
+
rows = []
|
|
65
|
+
for _ in range(REPEAT):
|
|
66
|
+
try: rows.append(fn())
|
|
67
|
+
except Exception as e: rows.append({"error": str(e)})
|
|
68
|
+
return label, rows
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def stat(rows, key):
|
|
72
|
+
vs = [r[key] for r in rows if "error" not in r and r.get(key) is not None]
|
|
73
|
+
if not vs: return None
|
|
74
|
+
return statistics.mean(vs), (statistics.stdev(vs) if len(vs) > 1 else 0.0)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def main():
|
|
78
|
+
print(f"GPT-2 workload, {REPEAT} repeats per mode\n")
|
|
79
|
+
rs = []
|
|
80
|
+
for label, fn in [("Bare (timing only)", mode_bare),
|
|
81
|
+
("CLI: codegreen run", mode_cli_run),
|
|
82
|
+
("Session (manual)", mode_session)]:
|
|
83
|
+
print(f"-- running {label}")
|
|
84
|
+
rs.append(repeat_run(label, fn))
|
|
85
|
+
|
|
86
|
+
print(f"\n{'mode':<22} {'energy_j (mean +/- std)':<28} {'power_w':<10} {'wall_s':<14} runs")
|
|
87
|
+
print("-" * 92)
|
|
88
|
+
base_e = base_w = None
|
|
89
|
+
for label, rows in rs:
|
|
90
|
+
ok = [r for r in rows if "error" not in r]
|
|
91
|
+
e = stat(rows, "energy_j"); p = stat(rows, "power_w"); w = stat(rows, "wall_s")
|
|
92
|
+
if not ok:
|
|
93
|
+
print(f"{label:<22} ERROR")
|
|
94
|
+
continue
|
|
95
|
+
if e and base_e is None and "Session" not in label and "CLI" in label:
|
|
96
|
+
base_e = e[0]
|
|
97
|
+
if w and base_w is None: base_w = w[0]
|
|
98
|
+
e_str = f"{e[0]:>9.2f} +/- {e[1]:<6.2f}" if e else " n/a "
|
|
99
|
+
e_pct = f"({100*(e[0]-base_e)/base_e:+5.2f}%)" if (e and base_e) else " "
|
|
100
|
+
p_str = f"{p[0]:>5.1f} W" if p else " n/a "
|
|
101
|
+
w_str = f"{w[0]:>4.2f} s ({100*(w[0]-base_w)/base_w:+4.1f}%)" if (w and base_w) else f"{w[0]:>4.2f} s"
|
|
102
|
+
print(f"{label:<22} {e_str} J {e_pct} {p_str:<10} {w_str:<14} {len(ok)}/{REPEAT}")
|
|
103
|
+
|
|
104
|
+
json.dump({"repeat": REPEAT, "results": rs}, open("/tmp/cg_modes_compare.json", "w"), indent=2, default=str)
|
|
105
|
+
print(f"\nraw JSON: /tmp/cg_modes_compare.json")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
main()
|
|
@@ -12,10 +12,10 @@ try:
|
|
|
12
12
|
from importlib.metadata import version as _pkg_version
|
|
13
13
|
__version__ = _pkg_version("codegreen")
|
|
14
14
|
except Exception:
|
|
15
|
-
__version__ = "0.
|
|
15
|
+
__version__ = "0.4.1" # fallback for dev/editable installs
|
|
16
16
|
__author__ = "Saurabhsingh Rajput"
|
|
17
17
|
__email__ = "saurabh@dal.ca"
|
|
18
|
-
__description__ = "Know the true energy cost of your code
|
|
18
|
+
__description__ = "Know the true energy cost of your code"
|
|
19
19
|
|
|
20
20
|
# Ensure package root is on sys.path for imports
|
|
21
21
|
import sys as _sys
|
|
@@ -25,9 +25,26 @@ _install_dir = str(_Path(__file__).resolve().parent.parent)
|
|
|
25
25
|
if _install_dir not in _sys.path:
|
|
26
26
|
_sys.path.insert(0, _install_dir)
|
|
27
27
|
|
|
28
|
+
# Manual API symbols are lazy-loaded so that `import codegreen` (for the CLI,
|
|
29
|
+
# instrumenter, or analyzer) does NOT pull in the runtime module and register
|
|
30
|
+
# its atexit hook. The runtime is loaded only when a user actually accesses
|
|
31
|
+
# Session / TaskResult / task.
|
|
32
|
+
_LAZY_RUNTIME_ATTRS = {"Session", "TaskResult", "task"}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def __getattr__(name):
|
|
36
|
+
if name in _LAZY_RUNTIME_ATTRS:
|
|
37
|
+
from codegreen.instrumentation.language_runtimes.python import codegreen_runtime as _rt
|
|
38
|
+
return getattr(_rt, name)
|
|
39
|
+
raise AttributeError(f"module 'codegreen' has no attribute {name!r}")
|
|
40
|
+
|
|
41
|
+
|
|
28
42
|
__all__ = [
|
|
29
43
|
"__version__",
|
|
30
44
|
"__author__",
|
|
31
45
|
"__email__",
|
|
32
46
|
"__description__",
|
|
47
|
+
"Session",
|
|
48
|
+
"TaskResult",
|
|
49
|
+
"task",
|
|
33
50
|
]
|
|
@@ -249,3 +249,71 @@ def _render_matplotlib(points: list[dict[str, Any]], path: Path) -> None:
|
|
|
249
249
|
fig.tight_layout(rect=[0, 0, 1, 0.96])
|
|
250
250
|
fig.savefig(path, dpi=150, bbox_inches="tight", facecolor=BG)
|
|
251
251
|
plt.close(fig)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def export_session_plot(report: dict, path: Path) -> None:
|
|
255
|
+
"""Render a power-vs-time chart from a codegreen.Session report.
|
|
256
|
+
Expects report["tasks"] with each task having `timeseries` of {t,j,w,d}."""
|
|
257
|
+
tasks = [t for t in report.get("tasks", []) if t.get("timeseries")]
|
|
258
|
+
if not tasks:
|
|
259
|
+
return
|
|
260
|
+
path = Path(path)
|
|
261
|
+
if path.suffix == ".html":
|
|
262
|
+
_render_session_plotly(tasks, path)
|
|
263
|
+
elif path.suffix in (".png", ".svg", ".pdf"):
|
|
264
|
+
_render_session_matplotlib(tasks, path)
|
|
265
|
+
else:
|
|
266
|
+
_render_session_plotly(tasks, path.with_suffix(".html"))
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def _render_session_plotly(tasks: list, path: Path) -> None:
|
|
270
|
+
try:
|
|
271
|
+
import plotly.graph_objects as go
|
|
272
|
+
except ImportError:
|
|
273
|
+
return
|
|
274
|
+
fig = go.Figure()
|
|
275
|
+
t0_ns = min(s["t"] for t in tasks for s in t["timeseries"])
|
|
276
|
+
for t in tasks:
|
|
277
|
+
ts = t["timeseries"]
|
|
278
|
+
x = [(s["t"] - t0_ns) / 1e9 for s in ts]
|
|
279
|
+
y = [s["w"] for s in ts]
|
|
280
|
+
fig.add_trace(go.Scatter(
|
|
281
|
+
x=x, y=y, mode="lines", name=t["name"],
|
|
282
|
+
line=dict(width=1),
|
|
283
|
+
hovertemplate="t=%{x:.3f}s P=%{y:.1f}W<extra>" + t["name"] + "</extra>",
|
|
284
|
+
))
|
|
285
|
+
fig.update_layout(
|
|
286
|
+
template="plotly_dark",
|
|
287
|
+
paper_bgcolor=BG, plot_bgcolor=CARD,
|
|
288
|
+
title=f"CodeGreen Session Power Trace ({len(tasks)} task(s))",
|
|
289
|
+
xaxis_title="Time (s)", yaxis_title="Power (W)",
|
|
290
|
+
height=420, showlegend=True,
|
|
291
|
+
font=dict(color=TXT),
|
|
292
|
+
)
|
|
293
|
+
fig.write_html(str(path), include_plotlyjs=True, full_html=True)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _render_session_matplotlib(tasks: list, path: Path) -> None:
|
|
297
|
+
try:
|
|
298
|
+
import matplotlib
|
|
299
|
+
matplotlib.use("Agg")
|
|
300
|
+
import matplotlib.pyplot as plt
|
|
301
|
+
except ImportError:
|
|
302
|
+
return
|
|
303
|
+
fig, ax = plt.subplots(figsize=(10, 4), facecolor=BG)
|
|
304
|
+
ax.set_facecolor(CARD)
|
|
305
|
+
t0_ns = min(s["t"] for t in tasks for s in t["timeseries"])
|
|
306
|
+
for t in tasks:
|
|
307
|
+
ts = t["timeseries"]
|
|
308
|
+
x = [(s["t"] - t0_ns) / 1e9 for s in ts]
|
|
309
|
+
y = [s["w"] for s in ts]
|
|
310
|
+
ax.plot(x, y, lw=0.8, label=t["name"])
|
|
311
|
+
ax.set_xlabel("Time (s)", color=TXT)
|
|
312
|
+
ax.set_ylabel("Power (W)", color=TXT)
|
|
313
|
+
ax.set_title("CodeGreen Session Power Trace", color=CG)
|
|
314
|
+
ax.legend(loc="upper right", fontsize=8)
|
|
315
|
+
ax.grid(alpha=0.15)
|
|
316
|
+
ax.tick_params(colors=TXT)
|
|
317
|
+
fig.tight_layout()
|
|
318
|
+
fig.savefig(path, dpi=150, bbox_inches="tight", facecolor=BG)
|
|
319
|
+
plt.close(fig)
|
|
@@ -2428,7 +2428,7 @@ def run_command(
|
|
|
2428
2428
|
budget: Annotated[Optional[float], typer.Option("--budget", help="Energy budget in Joules (fail if exceeded)")] = None,
|
|
2429
2429
|
include_warmup: Annotated[bool, typer.Option("--include-warmup", help="Measure energy during warmup and include in results")] = False,
|
|
2430
2430
|
):
|
|
2431
|
-
"""[bold]Measure energy[/bold] of any shell command
|
|
2431
|
+
"""[bold]Measure energy[/bold] of any shell command with hardware-level precision.
|
|
2432
2432
|
|
|
2433
2433
|
[bold]Important:[/bold] Use [cyan]--[/cyan] before commands that have their own flags.
|
|
2434
2434
|
Without it, flags like -c or -jar are parsed as codegreen options and will fail.
|