# AI Agents Can Optimize Code. But Where's the Evidence?

> An optimization isn't an improvement until you measure it.

- Published: 2026-11-20
- Canonical: https://www.gitdotme.com/blog-ai-agents-performance-optimization-evidence

Imagine assigning an AI coding agent a straightforward task: make an API endpoint faster.

The agent analyzes the implementation, identifies a potentially inefficient operation, introduces caching, and opens a pull request.

The code looks cleaner. The tests pass. The agent explains why the new implementation should be faster.

It even summarizes the optimization in its pull request description.

But there is something missing.

**How much faster is it?**

Was the change measured under a representative workload? Does it improve the 95th-percentile response time or only the average? Did the cache reduce database calls while increasing memory consumption?

And if the optimization does improve performance, how much engineering effort will be needed to maintain it?

These are different questions.

Yet they point toward the same principle:

**An optimization isn't an improvement until you measure it.**

As coding agents become more capable, this distinction is becoming increasingly important.

## Writing Faster Code Is Not the Same as Proving It Is Faster

Software performance optimization has always required more than producing code that looks efficient.

A developer might replace one data structure with another, eliminate repeated computations, reduce allocation overhead, or introduce caching.

Each change can be justified through technical reasoning.

But technical reasoning alone does not establish its actual impact.

Modern software systems contain complex interactions between applications, databases, networks, memory, storage, operating systems, and production workloads.

A locally sensible optimization can have unexpected consequences elsewhere.

For example, caching may improve response times while increasing memory use.

Parallel processing may reduce execution time for individual tasks while creating contention under high load.

A new algorithm may perform better for small inputs but worse for large ones.

Even a successful microbenchmark may fail to represent how the system behaves in production.

This is why software performance engineering depends on measurement.

It is not enough to explain why a change should be faster.

We need evidence that it actually is, under the conditions that matter.

And when AI agents generate the optimization, the same standard should apply.

## What Research on 2,260 Performance PRs Reveals

An October 2026 [preprint](https://arxiv.org/abs/2610.03969), *How Do Coding Agents Optimize Software and Report Performance Validation? A Large-Scale Empirical Study of Open-Source Pull Requests*, examined how AI coding agents and human developers propose and validate software performance optimizations.

Huiyun Peng and colleagues analyzed **1,130 agent-authored and 1,130 human-authored performance-related pull requests** collected through June 2026. The expanded preprint builds on an earlier, smaller MSR 2026 pilot study; its larger dataset is not a peer-reviewed MSR conference result.

The results are revealing.

Agent-authored performance PRs were merged at a rate of **54.4%**, compared with **73.3%** for human-authored PRs.

That difference deserves attention, but it should not be interpreted as proof that AI-generated optimizations are inherently worse.

Pull-request acceptance depends on many factors, including project expectations, contribution context, maintainer decisions, and change characteristics.

The study does not isolate AI authorship as the sole cause of the merge-rate gap.

The more interesting findings concern how contributors support their performance claims.

**AI agents and humans reported performance validation at surprisingly similar rates.**

Validation evidence appeared in **82.3% of 1,129 classifiable agent-authored PRs** and **80.6% of 1,129 classifiable human-authored PRs**. The difference was not statistically significant.

So the central problem is not simply that coding agents fail to report validation.

The problem is what that reported validation actually demonstrates.

## Validation Is Not Necessarily Measurement

When the researchers examined the primary form of validation evidence, a more informative difference emerged.

Among **918 agent-authored and 901 human-authored PRs with classified validation evidence**, **46.1% of agent-authored PRs** relied primarily on benchmark-based evidence, compared with **57.2% of human-authored PRs**.

Agent-authored PRs relied more frequently on static reasoning: **51.4%**, compared with **39.3%** for human-authored PRs.

Static reasoning means explaining why a code transformation should improve performance based on its structure or expected behavior.

Such reasoning can be valuable.

Understanding algorithmic complexity, unnecessary allocations, repeated operations, or redundant database calls is an essential part of software optimization.

But a plausible explanation is not equivalent to an observed performance improvement.

Consider two pull-request descriptions.

The first says:

*This implementation removes an unnecessary loop and should reduce processing overhead.*

The second reports that repeated tests under a specified workload reduced median execution time, while also documenting memory consumption and relevant experimental conditions.

Both might describe a legitimate optimization.

But they provide different levels of evidence.

The first describes an expected improvement.

The second provides measurements that others can examine and attempt to reproduce.

Neither automatically proves a production benefit. Even quantitative results can be misleading when workloads or measurement methods are inappropriate.

That is precisely why the quality of validation matters.

There is also an encouraging finding in the research.

By the second quarter of 2026, benchmark-based evidence had become the primary validation type in **60.1% of agent-authored PRs with classified validation evidence**, compared with **58.7% of the corresponding human-authored PRs**.

The gap observed across the full study period had narrowed and slightly reversed at that endpoint.

The lesson is not that agents cannot learn better validation practices.

It is that **performance evidence should be a requirement of the workflow, not an optional part of the agent's explanation.**

## Half of the Reported Validation Lacks a Performance Number

Perhaps the study's most important finding is not the difference between agents and humans.

It is the weakness shared by both groups.

In the study's metric-reporting analysis of PRs with validation evidence and an optimization label, only **437 of 858 agent-authored PRs (50.9%)** and **441 of 841 human-authored PRs (52.4%)** contained at least one extractable quantitative performance metric.

In other words, nearly half of the relevant PRs in both groups reported validation without an identifiable numerical performance result.

That does not necessarily mean those contributors performed no measurements.

The researchers analyzed information available in PR artifacts. Some evaluations may have been conducted without their numerical results being recorded in the material examined.

Nevertheless, the absence of reported quantitative evidence makes an optimization harder for reviewers to evaluate independently.

It also makes future comparisons more difficult.

If an optimization claims to improve performance but records no baseline, no measured result, and no experimental conditions, how should another engineer determine whether the change was beneficial?

And how can a team know whether a later modification preserved that benefit?

Performance optimization needs more than a successful build, a green test suite, or a convincing technical explanation.

**It needs evidence that can be examined, compared, and reproduced.**

## One Performance Number May Still Be Insufficient

The research identifies another limitation.

Among the **878 pull requests that reported at least one quantitative performance metric, 501 (57.1%) reported exactly one**.

A single metric may be appropriate for some changes.

But optimization is frequently a matter of trade-offs.

Consider a hypothetical caching change that reduces the median response time of an endpoint from 120 milliseconds to 85 milliseconds.

That looks promising.

Now suppose the change also increases memory consumption significantly and worsens response times for requests that miss the cache.

Would it still be considered successful?

The answer depends on the system's requirements, workload, capacity, and performance objectives.

This is why engineering teams should avoid treating optimization as a single-number competition.

Depending on the change, relevant dimensions may include:

- **Latency:** Average response time, tail latency, and variation under load.
- **Throughput:** Requests or operations processed per unit of time.
- **Resource consumption:** CPU, memory, storage, or network utilization.
- **Scalability:** How performance changes as concurrency and workload increase.
- **Operational cost:** Infrastructure resources required to achieve the improvement.
- **Correctness and reliability:** Whether the optimization introduces functional or operational regressions.

Not every optimization requires measuring all of these.

But teams should explicitly identify the primary objective and the likely trade-offs.

A performance improvement that looks impressive in isolation can be much less valuable when the broader system costs are considered.

## A Better Definition of Done for Agent-Generated Optimizations

If AI agents are going to participate meaningfully in performance engineering, their work should be evaluated against measurable acceptance criteria.

The answer is not necessarily more human review.

It is more explicit evidence requirements and stronger automated verification. Clear acceptance criteria also help [keep agent work within the requested scope](https://www.gitdotme.com/blog-ai-coding-agents-scope-problem).

### 1. Define the performance objective before changing the code

An instruction such as *make this endpoint faster* is ambiguous.

A stronger task identifies the workload, relevant performance metric, acceptable trade-offs, and success criteria.

For example, an optimization request might aim to reduce 95th-percentile latency under a representative workload without exceeding a defined memory budget.

The objective must be clear before an agent proposes a solution.

### 2. Establish a reproducible baseline

Performance improvements require a meaningful comparison.

Record the relevant measurements before the change.

Use a controlled environment wherever possible, including consistent input data, dependencies, hardware resources, and workload characteristics.

Measurements should be repeated when natural variability could influence the result.

Without a baseline, an improvement percentage may be little more than an unsupported claim.

### 3. Require quantitative before-and-after evidence

A pull request should report the measured impact of the proposed optimization.

That evidence should describe the test conditions and the relevant results.

It should also make clear what was not evaluated.

A result obtained from a narrow microbenchmark should not be presented as proof of an equivalent improvement in end-to-end production behavior.

### 4. Measure relevant trade-offs

If a change is intended to improve latency, examine whether it materially affects memory, throughput, CPU consumption, or other relevant constraints.

The appropriate metrics depend on the optimization.

The goal is not to collect every available number.

It is to avoid hiding an important cost behind a favorable headline metric.

### 5. Keep performance verification independent

Where possible, use benchmark harnesses, CI performance checks, profiling tools, or other validation mechanisms that are not dependent on the coding agent's own narrative.

An agent can propose an optimization and summarize the results.

But the evidence should be independently inspectable.

Human reviewers remain responsible for evaluating whether the tests are representative and the trade-offs are acceptable.

### 6. Reevaluate after deployment

Some performance problems only emerge under real workloads.

Production observability, canary deployments, regression monitoring, and rollback procedures can help verify whether the intended improvements persist.

An optimization should not be considered permanently successful merely because its initial benchmark passed.

Its value depends on how it behaves in the system over time.

## Performance Improvement Has an Engineering Cost

There is another dimension that performance benchmarks do not capture.

**How much engineering effort did the optimization require?**

Imagine two changes that deliver a similar independently verified improvement in application performance.

The first introduces a small, understandable modification to an existing function.

The second introduces a new caching layer, several dependencies, additional configuration, and significant maintenance responsibilities.

Both might improve runtime performance.

But they do not necessarily create the same engineering outcome.

The second approach may be justified when it supports larger workloads or additional requirements.

It may also impose unnecessary complexity.

Determining which approach is better requires understanding the engineering effort involved and what happens to the implementation after it is delivered.

A performance gain achieved through extensive rework and fragile architecture may have a different long-term value from a similar gain delivered through a durable, maintainable change. The [maintenance cost of AI-assisted coding](https://www.gitdotme.com/blog-hidden-maintenance-tax-ai-assisted-coding) is one reason to examine changes after merge.

This introduces two complementary questions:

**Did the optimization improve the software's runtime performance?**

**Did the work required to achieve that improvement create lasting engineering value?**

These questions should be measured separately.

## Where GitMe Fits

Runtime performance and engineering productivity are different measurement domains.

Application performance tools can evaluate latency, throughput, resource consumption, and system behavior.

GitMe focuses on modeled engineering effort, AI participation, and the lifecycle of software contributions.

The two perspectives complement one another.

**Real Effort Value (REV)** models the baseline engineering effort represented by a contribution. It is not a measure of actual employee working hours or verified business value.

This allows teams to look beyond the number of changed lines or commits when evaluating the engineering work involved.

**AI Effort Share** provides visibility into modeled AI participation in that engineering effort.

**AI Leverage** helps examine the modeled relationship between engineering output and estimated human effort, rather than treating AI usage itself as a productivity result. It can inform [questions about AI Leverage's limits](https://www.gitdotme.com/blog-ai-leverage-saturation-point).

**Rework and refactoring signals** provide insight into subsequent changes made to an implementation.

Some revisions correct defects or replace unsuccessful approaches. Others represent healthy improvements and necessary refactoring.

**Effort Survival Cohort** examines how modeled engineering effort from earlier periods persists as the codebase evolves.

Together, these measures help teams investigate the engineering lifecycle of AI-assisted optimization work.

Consider an organization that independently verifies a meaningful improvement in application performance.

GitMe can provide a complementary perspective on the modeled engineering effort associated with the changes, the AI contribution, the subsequent rework, and the persistence of that work over time.

That helps engineering leaders ask whether a technically successful optimization was also a sustainable engineering contribution.

There is an important boundary.

**GitMe does not directly measure runtime performance, execute benchmarks, or prove that an agent-generated change improved latency or throughput.**

Those outcomes require appropriate application-performance measurement.

And GitMe's repository-derived signals do not, by themselves, establish the business value or causal impact of a specific optimization.

The stronger approach is to combine independently verified performance results with a separate assessment of engineering effort and durability.

Neither perspective should be mistaken for the other.

## The Best Optimization Is Not Always the Fastest One

Performance optimization is not a contest to produce the lowest benchmark number at any cost.

A solution that consumes excessive memory, introduces fragile dependencies, or increases future maintenance effort may be less attractive than a slightly slower but more sustainable alternative.

Conversely, a large architectural investment may be justified when it delivers meaningful improvements at scale.

The right choice depends on system requirements and the consequences of the change.

That is why engineering leaders should distinguish between three forms of success:

**Implementation success:** The proposed change works and passes the required functional checks.

**Performance success:** Reliable measurements demonstrate that the change improves the intended performance objective without unacceptable trade-offs.

**Engineering success:** The implementation achieves that result with justified effort and remains maintainable and useful over time.

These dimensions are related, but they are not interchangeable.

A coding agent can produce a technically correct implementation without establishing a performance improvement.

It can demonstrate a performance improvement without producing the most sustainable engineering solution.

And a contribution can be durable without delivering the performance outcome originally intended.

Good measurement makes those distinctions visible.

## The Future of AI Optimization Needs Evidence

AI coding agents are becoming increasingly capable of proposing and implementing performance optimizations.

The research suggests that their optimization techniques are becoming more similar to those used by human developers.

But it also reveals a shared weakness in how performance benefits are demonstrated.

Reported validation is not always quantitative.

Quantitative evidence is not always multidimensional.

And even benchmark-based evidence does not automatically establish that an improvement will survive real production workloads.

The next step is not simply to generate more optimization patches.

It is to establish stronger evidence for the improvements they claim to deliver.

That means measuring actual system performance, evaluating trade-offs, and understanding the engineering effort required to build and maintain those improvements.

**AI can propose an optimization. Benchmarks can test its performance. Engineering analytics can help evaluate the effort and durability behind it.**

The objective is not merely faster code.

It is demonstrably better software, produced through engineering work that continues to deliver value.

[Explore GitMe](https://panel.gitdotme.com/signup) to understand AI Leverage, engineering effort, rework, and the value that lasts.

## Sources

1. Peng, H., Calvo, R., Kalu, K. G., & Davis, J. C. (2026). [How Do Coding Agents Optimize Software and Report Performance Validation? A Large-Scale Empirical Study of Open-Source Pull Requests](https://arxiv.org/abs/2610.03969). arXiv:2610.03969, October 2026. Preprint analyzing 2,260 performance-related open-source pull requests.
2. Peng, H., Qiu, A. Z., Calvo, R., Kalu, K. G., & Davis, J. C. (2026). [How Do Agents Perform Code Optimization? An Empirical Study](https://doi.org/10.1145/3793302.3793564). Proceedings of the 23rd International Conference on Mining Software Repositories (MSR 2026). Earlier pilot study examining 407 performance-related PRs. Included for research context; its smaller dataset and results must not be confused with those of the expanded October study.
