Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
04a87cf
fix: add Jest 30 support, fix time limit, and fix async function looping
mohammedahmed18 Feb 3, 2026
4c61d08
Merge branch 'main' into fix/js-jest30-loop-runner
mohammedahmed18 Feb 3, 2026
a3764f1
Merge branch 'main' of github.com:codeflash-ai/codeflash into fix/js-…
mohammedahmed18 Feb 3, 2026
4157534
fix: use getter functions for env var constants in capture.js
mohammedahmed18 Feb 3, 2026
017bde1
refactor: improve code quality and documentation in loop-runner and c…
mohammedahmed18 Feb 3, 2026
71b38d5
fix: Parse timing markers from console output for JavaScript benchmar…
mohammedahmed18 Feb 3, 2026
7273f27
chore: trigger CI workflows
mohammedahmed18 Feb 3, 2026
b83e516
fix: use lazy % formatting for logger.debug to pass ruff G004
mohammedahmed18 Feb 3, 2026
0592d92
Merge branch 'main' into fix/js-jest30-loop-runner
mohammedahmed18 Feb 4, 2026
b4d0b0f
fix: support monorepo hoisted dependencies in JS requirements check
mohammedahmed18 Feb 4, 2026
3b56d24
debug: add extensive Jest execution logging for troubleshooting
mohammedahmed18 Feb 4, 2026
9cd5d5a
fix: calculate correct import paths for JavaScript tests in temp dire…
mohammedahmed18 Feb 4, 2026
0a8d120
fix: preserve ./ prefix in JS import paths and fix TestType enum
mohammedahmed18 Feb 4, 2026
6febd69
debug: add extensive performance test debugging
mohammedahmed18 Feb 4, 2026
6c74adc
fix: disable custom loop-runner to enable basic performance testing
mohammedahmed18 Feb 4, 2026
202bdc4
Merge branch 'main' into fix/js-jest30-loop-runner
mohammedahmed18 Feb 4, 2026
bab3bd4
style: auto-fix linting issues
github-actions[bot] Feb 4, 2026
535c640
fix: resolve all linting issues from ruff and mypy
mohammedahmed18 Feb 4, 2026
d0b859a
Optimize PrComment.to_json
codeflash-ai[bot] Feb 4, 2026
c151b6c
Merge pull request #1383 from codeflash-ai/codeflash/optimize-pr1318-…
claude[bot] Feb 4, 2026
ae31ca7
Fix JavaScript test generation and benchmarking
mohammedahmed18 Feb 5, 2026
9bb05f6
style: auto-fix linting issues
github-actions[bot] Feb 5, 2026
8fcb8cc
cleanup
mohammedahmed18 Feb 5, 2026
67ea0c9
Merge branch 'fix/js-jest30-loop-runner' of github.com:codeflash-ai/c…
mohammedahmed18 Feb 5, 2026
a6b9364
fix: include same-class helper methods inside class wrapper for TypeS…
mohammedahmed18 Feb 6, 2026
f800ae3
Merge branch 'main' into fix/js-jest30-loop-runner
mohammedahmed18 Feb 6, 2026
b65711d
fix: resolve merge conflict in function_optimizer.py
github-actions[bot] Feb 6, 2026
4545b8c
fix: add export keywords to remaining JavaScript/TypeScript tests
mohammedahmed18 Feb 6, 2026
183d800
fix: detect CommonJS exports (module.exports) for function discovery
mohammedahmed18 Feb 6, 2026
6c23255
version upgrade for cf package
mohammedahmed18 Feb 6, 2026
ce13a6d
Merge branch 'main' into fix/js-jest30-loop-runner
Saga4 Feb 9, 2026
599a0e3
fix: resolve merge conflicts in verifier.py
github-actions[bot] Feb 9, 2026
dcd9e2a
some fixes for test runner and instrumentation
mohammedahmed18 Feb 11, 2026
1b8f701
Merge branch 'fix/js-jest30-loop-runner' of github.com:codeflash-ai/c…
mohammedahmed18 Feb 11, 2026
175226b
fix: correct loop index calculation in JS performance benchmarking
mohammedahmed18 Feb 12, 2026
536c1d0
remove debug statements
mohammedahmed18 Feb 12, 2026
e9b7154
Merge branch 'main' of github.com:codeflash-ai/codeflash into fix/js-…
mohammedahmed18 Feb 12, 2026
e07fd1d
fix tests
mohammedahmed18 Feb 12, 2026
4c9f4ef
Optimize StandaloneCallTransformer._parse_bracket_standalone_call
codeflash-ai[bot] Feb 12, 2026
6b77be5
ignore calls inside string litrals for instrumentation and fix e2e test
mohammedahmed18 Feb 12, 2026
f5dd109
Merge pull request #1465 from codeflash-ai/codeflash/optimize-pr1318-…
mohammedahmed18 Feb 12, 2026
9937fe0
fixes for unit tests
mohammedahmed18 Feb 12, 2026
4dedb9f
Merge branch 'fix/js-jest30-loop-runner' of github.com:codeflash-ai/c…
mohammedahmed18 Feb 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions code_to_optimize/js/code_to_optimize_js/bubble_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ function bubbleSort(arr) {
const result = arr.slice();
const n = result.length;

for (let i = 0; i < n; i++) {
for (let j = 0; j < n - 1; j++) {
if (result[j] > result[j + 1]) {
const temp = result[j];
result[j] = result[j + 1];
result[j + 1] = temp;
if (n <= 1) return result;

for (let i = 0; i < n - 1; i++) {
let swapped = false;
const limit = n - i - 1;
for (let j = 0; j < limit; j++) {
const a = result[j];
const b = result[j + 1];
if (a > b) {
result[j] = b;
result[j + 1] = a;
swapped = true;
}
}
if (!swapped) break;
}

return result;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 11 additions & 23 deletions codeflash/code_utils/code_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,32 @@ def is_glob_pattern(path_str: str) -> bool:


def normalize_ignore_paths(paths: list[str], base_path: Path | None = None) -> list[Path]:
"""Normalize ignore paths, expanding glob patterns and resolving paths.

Accepts a list of path strings that can be either:
- Literal paths (relative or absolute): e.g., "node_modules", "/absolute/path"
- Glob patterns: e.g., "**/*.test.js", "dist/*", "*.log"

Args:
paths: List of path strings (literal paths or glob patterns).
base_path: Base path for resolving relative paths and patterns.
If None, uses current working directory.

Returns:
List of resolved Path objects, deduplicated.

"""
if base_path is None:
base_path = Path.cwd()

base_path = base_path.resolve()
normalized: set[Path] = set()

for path_str in paths:
if not path_str:
continue

path_str = str(path_str)

if is_glob_pattern(path_str):
# It's a glob pattern - expand it
# Use base_path as the root for glob expansion
pattern_path = base_path / path_str
# glob returns an iterator of matching paths
# pathlib requires relative glob patterns
path_str = path_str.removeprefix("./")
if path_str.startswith("/"):
path_str = path_str.lstrip("/")

for matched_path in base_path.glob(path_str):
if matched_path.exists():
normalized.add(matched_path.resolve())
normalized.add(matched_path.resolve())
else:
# It's a literal path
path_obj = Path(path_str)
if not path_obj.is_absolute():
path_obj = base_path / path_obj
if path_obj.exists():
normalized.add(path_obj.resolve())
# Silently skip non-existent literal paths (e.g., .next, dist before build)

return list(normalized)

Expand Down
41 changes: 23 additions & 18 deletions codeflash/code_utils/time_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import annotations

import datetime as dt
import re

import humanize


def humanize_runtime(time_in_ns: int) -> str:
runtime_human: str = str(time_in_ns)
Expand All @@ -14,22 +9,32 @@ def humanize_runtime(time_in_ns: int) -> str:

if time_in_ns / 1000 >= 1:
time_micro = float(time_in_ns) / 1000
runtime_human = humanize.precisedelta(dt.timedelta(microseconds=time_micro), minimum_unit="microseconds")

units = re.split(r",|\s", runtime_human)[1]

if units in {"microseconds", "microsecond"}:
# Direct unit determination and formatting without external library
if time_micro < 1000:
runtime_human = f"{time_micro:.3g}"
elif units in {"milliseconds", "millisecond"}:
runtime_human = "%.3g" % (time_micro / 1000)
elif units in {"seconds", "second"}:
runtime_human = "%.3g" % (time_micro / (1000**2))
elif units in {"minutes", "minute"}:
runtime_human = "%.3g" % (time_micro / (60 * 1000**2))
elif units in {"hour", "hours"}: # hours
runtime_human = "%.3g" % (time_micro / (3600 * 1000**2))
units = "microseconds" if time_micro >= 2 else "microsecond"
elif time_micro < 1000000:
time_milli = time_micro / 1000
runtime_human = f"{time_milli:.3g}"
units = "milliseconds" if time_milli >= 2 else "millisecond"
elif time_micro < 60000000:
time_sec = time_micro / 1000000
runtime_human = f"{time_sec:.3g}"
units = "seconds" if time_sec >= 2 else "second"
elif time_micro < 3600000000:
time_min = time_micro / 60000000
runtime_human = f"{time_min:.3g}"
units = "minutes" if time_min >= 2 else "minute"
elif time_micro < 86400000000:
time_hour = time_micro / 3600000000
runtime_human = f"{time_hour:.3g}"
units = "hours" if time_hour >= 2 else "hour"
else: # days
runtime_human = "%.3g" % (time_micro / (24 * 3600 * 1000**2))
time_day = time_micro / 86400000000
runtime_human = f"{time_day:.3g}"
units = "days" if time_day >= 2 else "day"

runtime_human_parts = str(runtime_human).split(".")
if len(runtime_human_parts[0]) == 1:
if runtime_human_parts[0] == "1" and len(runtime_human_parts) > 1:
Expand Down
4 changes: 2 additions & 2 deletions codeflash/github/PrComment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def to_json(self) -> dict[str, Union[str, int, dict[str, dict[str, int]], list[B
}

if self.original_async_throughput is not None and self.best_async_throughput is not None:
result["original_async_throughput"] = str(self.original_async_throughput)
result["best_async_throughput"] = str(self.best_async_throughput)
result["original_async_throughput"] = self.original_async_throughput
result["best_async_throughput"] = self.best_async_throughput
Comment on lines +48 to +49
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential breaking API change: throughput fields changed from str to int

Previously these were serialized as str(self.original_async_throughput) and str(self.best_async_throughput). Now they're passed as raw int values. This JSON is sent to the CodeFlash API server (via cfapi.py where pr_comment.to_json() is called). If the server expects string values for these fields, this will cause a type mismatch or API error.

Verify the server-side API accepts int for these fields before merging.


return result

Expand Down
Loading
Loading