codegreen 0.3.15__tar.gz → 0.4.0__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.15 → codegreen-0.4.0}/CMakeLists.txt +6 -16
- {codegreen-0.3.15/codegreen.egg-info → codegreen-0.4.0}/PKG-INFO +33 -4
- {codegreen-0.3.15 → codegreen-0.4.0}/README.md +29 -1
- codegreen-0.4.0/benchmark/cg_vs_codecarbon_transformers.py +109 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/__init__.py +19 -2
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analyzer/plot.py +68 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/cli/cli.py +1 -1
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/cli/entrypoint.py +1 -2
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/config.json +2 -2
- codegreen-0.4.0/codegreen/instrumentation/language_runtimes/python/codegreen_runtime.py +761 -0
- {codegreen-0.3.15 → codegreen-0.4.0/codegreen.egg-info}/PKG-INFO +33 -4
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen.egg-info/SOURCES.txt +1 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen.egg-info/requires.txt +2 -1
- {codegreen-0.3.15 → codegreen-0.4.0}/pyproject.toml +4 -3
- {codegreen-0.3.15 → codegreen-0.4.0}/setup.py +54 -9
- codegreen-0.3.15/codegreen/instrumentation/language_runtimes/python/codegreen_runtime.py +0 -194
- {codegreen-0.3.15 → codegreen-0.4.0}/LICENSE +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/MANIFEST.in +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/__main__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/compilers.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/config.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/harness.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/profilers.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/results.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/suites/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/suites/base.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/suites/benchmarksgame.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/suites/dacapo.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/suites/perfopt.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/suites/renaissance.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/validation/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/validation/analysis.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/validation/experiments.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/benchmark/validation/reporting.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/_ts_java.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/builder.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/callgraph.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/dataflow.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/energy_flow.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/features.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/pdg.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/types.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analysis/cfg/visualization.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/analyzer/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/cli/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/ast_processor.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/bridge_analyze.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/bridge_instrument.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/config.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/configs/TEMPLATE.json +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/configs/c.json +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/configs/cpp.json +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/configs/java.json +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/configs/javascript.json +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/configs/python.json +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/engine.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/language_configs.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/language_engine.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/language_runtimes/c/codegreen_runtime.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/language_runtimes/cpp/codegreen/runtime.hpp +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/language_runtimes/java/codegreen/runtime/CodeGreenRuntime.java +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/instrumentation/language_runtimes/java/codegreen/runtime/CodeGreenStandaloneRuntime.java +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/utils/__init__.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/utils/binary.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen/utils/platform.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen.egg-info/dependency_links.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen.egg-info/entry_points.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen.egg-info/not-zip-safe +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/codegreen.egg-info/top_level.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/requirements.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/setup.cfg +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/tests/test_instrumentation.py +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/binarytrees/2.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/helloworld/1.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/knucleotide/1.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/mandelbrot/1-ffi.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/mandelbrot/1-mffi.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/nbody/2.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/nbody/5.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/nbody/8-i.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/nsieve/1.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/3.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/4.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/5-im.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/Programming-Language-Benchmarks/bench/algorithm/spectral-norm/6-im.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/aligned_indent.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/array.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/comment.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/compound_lit.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/cond.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/enum.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/expr.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/func.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/if_else.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/issue-1568.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/issue-2086.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/issue-4079.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/issue-4117.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/issue-4525.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/label.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/loop.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/no_braces.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/preproc_cond.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/preproc_func.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/string.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/struct.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/switch.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/ternary.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/indent/c/unfinished_comment.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/nvim-treesitter/tests/query/highlights/c/enums-as-constants.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/crates/cli/src/templates/PARSER_NAME.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/crates/cli/src/templates/py-binding.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/crates/generate/src/templates/alloc.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/crates/generate/src/templates/array.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/crates/highlight/include/tree_sitter/highlight.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/crates/tags/include/tree_sitter/tags.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/CMakeLists.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/binding_web/lib/tree-sitter.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/include/tree_sitter/api.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/alloc.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/alloc.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/array.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/atomic.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/clock.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/error_costs.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/get_changed_ranges.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/get_changed_ranges.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/host.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/language.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/language.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/length.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/lexer.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/lexer.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/lib.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/node.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/parser.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/parser.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/point.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/portable/endian.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/query.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/reduce_action.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/reusable_node.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/stack.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/stack.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/subtree.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/subtree.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/tree.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/tree.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/tree_cursor.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/tree_cursor.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/ts_assert.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode/ptypes.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode/umachine.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode/urename.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode/utf.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode/utf16.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode/utf8.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/unicode.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/wasm/stdlib.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/wasm/wasm-stdlib.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/wasm_store.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/lib/src/wasm_store.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/depends_on_column/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/epsilon_external_extra_tokens/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/epsilon_external_tokens/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/external_tokens/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/external_unicode_column_alignment/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/get_col_eof/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/get_col_should_hang_not_crash/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/inverted_external_token/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter/test/fixtures/test_grammars/uses_current_column/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/CMakeLists.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/bindings/c/tree_sitter/tree-sitter-c.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/bindings/python/tree_sitter_c/binding.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/bindings/swift/TreeSitterC/c.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/examples/cluster.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/examples/malloc.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/examples/parser.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/src/parser.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/src/tree_sitter/parser.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/test/highlight/keywords.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-c/test/highlight/names.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/CMakeLists.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/bindings/c/tree-sitter-cpp.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/bindings/python/tree_sitter_cpp/binding.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/bindings/swift/TreeSitterCPP/cpp.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/examples/marker-index.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/src/parser.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/src/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-cpp/src/tree_sitter/parser.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/CMakeLists.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/bindings/c/tree-sitter-java.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/bindings/python/tree_sitter_java/binding.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/bindings/swift/TreeSitterJava/java.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/src/parser.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-java/src/tree_sitter/parser.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/CMakeLists.txt +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/bindings/c/tree-sitter-python.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/bindings/python/tree_sitter_python/binding.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/bindings/swift/TreeSitterPython/python.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/src/parser.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/src/scanner.c +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/src/tree_sitter/alloc.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/src/tree_sitter/array.h +0 -0
- {codegreen-0.3.15 → codegreen-0.4.0}/third_party/tree-sitter-python/src/tree_sitter/parser.h +0 -0
|
@@ -15,28 +15,18 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
15
15
|
find_package(PkgConfig)
|
|
16
16
|
find_package(Threads REQUIRED)
|
|
17
17
|
|
|
18
|
-
#
|
|
18
|
+
# GPU libraries are loaded at runtime (dlopen/LoadLibrary), not linked.
|
|
19
|
+
# These checks are informational only.
|
|
19
20
|
find_library(NVML_LIBRARY nvidia-ml PATHS
|
|
20
21
|
/usr/local/cuda/lib64 /usr/lib/x86_64-linux-gnu
|
|
21
22
|
"C:/Windows/System32" "$ENV{ProgramFiles}/NVIDIA Corporation/NVSMI")
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"$ENV{CUDA_PATH}/include")
|
|
25
|
-
find_library(ROCM_SMI_LIBRARY rocm_smi64 PATHS /opt/rocm/lib)
|
|
26
|
-
find_path(ROCM_SMI_INCLUDE_DIR rocm_smi.h PATHS /opt/rocm/include/rocm_smi)
|
|
27
|
-
|
|
28
|
-
if(NVML_LIBRARY AND NVML_INCLUDE_DIR)
|
|
29
|
-
message(STATUS "NVML found: ${NVML_LIBRARY}")
|
|
30
|
-
set(HAVE_NVML ON)
|
|
31
|
-
else()
|
|
32
|
-
set(HAVE_NVML OFF)
|
|
23
|
+
if(NVML_LIBRARY)
|
|
24
|
+
message(STATUS "NVML found (runtime-loaded): ${NVML_LIBRARY}")
|
|
33
25
|
endif()
|
|
34
26
|
|
|
35
|
-
|
|
27
|
+
find_library(ROCM_SMI_LIBRARY rocm_smi64 PATHS /opt/rocm/lib)
|
|
28
|
+
if(ROCM_SMI_LIBRARY)
|
|
36
29
|
message(STATUS "ROCm SMI found: ${ROCM_SMI_LIBRARY}")
|
|
37
|
-
set(HAVE_ROCM_SMI ON)
|
|
38
|
-
else()
|
|
39
|
-
set(HAVE_ROCM_SMI OFF)
|
|
40
30
|
endif()
|
|
41
31
|
|
|
42
32
|
# Global include directories
|
|
@@ -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.0
|
|
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,109 @@
|
|
|
1
|
+
"""Verify codegreen.Session against CodeCarbon EmissionsTracker on a transformers
|
|
2
|
+
fine-tune (mirrors https://docs.codecarbon.io/latest/how-to/transformers/).
|
|
3
|
+
|
|
4
|
+
Trackers run **sequentially** (not concurrent) to avoid double-instrumentation noise:
|
|
5
|
+
|
|
6
|
+
Phase 1: CodeCarbon-only -> 1 fine-tune (baseline reference)
|
|
7
|
+
Phase 2: CodeGreen-only -> 3 fine-tunes inside one Session, one per API form:
|
|
8
|
+
explicit start_task / stop_task
|
|
9
|
+
`with sess.task(...)` context manager
|
|
10
|
+
`@codegreen.task(...)` decorator
|
|
11
|
+
|
|
12
|
+
Each fine-tune trains on the same IMDB slice with the same TrainingArguments,
|
|
13
|
+
so per-task CG energy / time / power are directly comparable to the CC baseline.
|
|
14
|
+
|
|
15
|
+
Run: python -m benchmark.cg_vs_codecarbon_transformers [--n 128] [--epochs 1] [--batch 8]
|
|
16
|
+
"""
|
|
17
|
+
import argparse, json, os, time
|
|
18
|
+
|
|
19
|
+
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false")
|
|
20
|
+
os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _build_dataset_and_model_factory(model_name, n):
|
|
24
|
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
25
|
+
from datasets import load_dataset
|
|
26
|
+
tok = AutoTokenizer.from_pretrained(model_name)
|
|
27
|
+
ds = load_dataset("imdb", split=f"train[:{n}]")
|
|
28
|
+
ds = ds.map(lambda b: tok(b["text"], truncation=True, padding="max_length", max_length=128), batched=True)
|
|
29
|
+
ds = ds.rename_column("label", "labels")
|
|
30
|
+
ds.set_format("torch", columns=["input_ids", "attention_mask", "labels"])
|
|
31
|
+
return ds, lambda: AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _train_args(out, epochs, batch):
|
|
35
|
+
from transformers import TrainingArguments
|
|
36
|
+
return TrainingArguments(output_dir=out, num_train_epochs=epochs,
|
|
37
|
+
per_device_train_batch_size=batch, save_strategy="no",
|
|
38
|
+
report_to=[], disable_tqdm=True, logging_strategy="no", use_cpu=True)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _do_train(new_model, ds, out, epochs, batch):
|
|
42
|
+
from transformers import Trainer
|
|
43
|
+
Trainer(model=new_model(), args=_train_args(out, epochs, batch), train_dataset=ds).train()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def main():
|
|
47
|
+
p = argparse.ArgumentParser()
|
|
48
|
+
p.add_argument("--n", type=int, default=128)
|
|
49
|
+
p.add_argument("--epochs", type=int, default=1)
|
|
50
|
+
p.add_argument("--batch", type=int, default=8)
|
|
51
|
+
p.add_argument("--out", default="/tmp/cg_session.json")
|
|
52
|
+
p.add_argument("--model", default="distilbert-base-uncased")
|
|
53
|
+
args = p.parse_args()
|
|
54
|
+
|
|
55
|
+
ds, new_model = _build_dataset_and_model_factory(args.model, args.n)
|
|
56
|
+
|
|
57
|
+
# ---- Phase 1: CodeCarbon-only baseline ----
|
|
58
|
+
from codecarbon import EmissionsTracker
|
|
59
|
+
cc = EmissionsTracker(project_name="cg_vs_cc", output_dir="/tmp",
|
|
60
|
+
log_level="error", save_to_file=False)
|
|
61
|
+
cc.start()
|
|
62
|
+
t0 = time.perf_counter()
|
|
63
|
+
_do_train(new_model, ds, "/tmp/_cc", args.epochs, args.batch)
|
|
64
|
+
cc_wall = time.perf_counter() - t0
|
|
65
|
+
co2 = cc.stop()
|
|
66
|
+
cc_j = (cc.final_emissions_data.energy_consumed or 0.0) * 3.6e6
|
|
67
|
+
|
|
68
|
+
# ---- Phase 2: CodeGreen Session (3 forms in one session, sequential) ----
|
|
69
|
+
import codegreen
|
|
70
|
+
sess = codegreen.Session(output_file=args.out, record_time_series=True)
|
|
71
|
+
sess.start()
|
|
72
|
+
t0 = time.perf_counter()
|
|
73
|
+
|
|
74
|
+
sess.start_task("explicit_train")
|
|
75
|
+
_do_train(new_model, ds, "/tmp/_t1", args.epochs, args.batch)
|
|
76
|
+
sess.stop_task("explicit_train")
|
|
77
|
+
|
|
78
|
+
with sess.task("context_train"):
|
|
79
|
+
_do_train(new_model, ds, "/tmp/_t2", args.epochs, args.batch)
|
|
80
|
+
|
|
81
|
+
@codegreen.task("decorator_train")
|
|
82
|
+
def fine_tune():
|
|
83
|
+
_do_train(new_model, ds, "/tmp/_t3", args.epochs, args.batch)
|
|
84
|
+
fine_tune()
|
|
85
|
+
|
|
86
|
+
cg_wall = time.perf_counter() - t0
|
|
87
|
+
sess.stop()
|
|
88
|
+
|
|
89
|
+
rep = json.load(open(args.out))
|
|
90
|
+
tasks = {t["name"]: t for t in rep["tasks"]}
|
|
91
|
+
cg_total_tasks = sum(t["energy_j"] for t in rep["tasks"])
|
|
92
|
+
|
|
93
|
+
# Per-task delta vs CC baseline (CC ran 1 train; each CG task ran 1 train)
|
|
94
|
+
print(f"\n{args.model} | IMDB[:{args.n}] | {args.epochs} ep | batch={args.batch}\n")
|
|
95
|
+
print(f"Phase 1 (CodeCarbon, 1 train)")
|
|
96
|
+
print(f" wall {cc_wall:.2f} s energy {cc_j:.2f} J power {cc_j/cc_wall:.2f} W CO2 {co2*1000:.4f} g")
|
|
97
|
+
print(f"\nPhase 2 (CodeGreen Session, 3 trains sequential)")
|
|
98
|
+
print(f" total span energy {rep['total']['energy_j']:.2f} J power {rep['total']['power_w']:.2f} W wall {cg_wall:.2f} s")
|
|
99
|
+
print(f"\n task energy(J) dur(s) power(W) ts delta-vs-CC")
|
|
100
|
+
for name in ("explicit_train", "context_train", "decorator_train"):
|
|
101
|
+
t = tasks[name]
|
|
102
|
+
ts = len(t.get("time_series", []))
|
|
103
|
+
d = 100 * (t["energy_j"] - cc_j) / cc_j if cc_j else float("nan")
|
|
104
|
+
print(f" {name:<18} {t['energy_j']:>8.2f} {t['duration_s']:>6.2f} {t['power_w']:>7.2f} {ts:>5} {d:+7.2f}%")
|
|
105
|
+
print(f"\n domains captured: {list(tasks['explicit_train'].get('per_domain', {}).keys())}")
|
|
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.0" # 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.
|
|
@@ -15,8 +15,7 @@ _install_str = str(_install_dir)
|
|
|
15
15
|
if _install_str not in sys.path:
|
|
16
16
|
sys.path.insert(0, _install_str)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
os.chdir(_install_str)
|
|
18
|
+
os.environ.setdefault("CODEGREEN_INSTALL_DIR", _install_str)
|
|
20
19
|
|
|
21
20
|
from codegreen.cli.cli import main_cli
|
|
22
21
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.16",
|
|
3
3
|
"paths": {
|
|
4
4
|
"runtime_modules": {
|
|
5
5
|
"python": "runtime/codegreen_runtime.py",
|
|
@@ -166,6 +166,6 @@
|
|
|
166
166
|
"timestamp": null,
|
|
167
167
|
"environment_type": "unknown",
|
|
168
168
|
"detected_sensors": [],
|
|
169
|
-
"version": "0.3.
|
|
169
|
+
"version": "0.3.16"
|
|
170
170
|
}
|
|
171
171
|
}
|