Sample

int-c341924f25f9-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines72

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8160–1; higher is more readable
Dorn0.1080–1; higher is more readable
Mi0.2610–1; higher is more readable
LLOC41Logical lines; fewer is more readable
DeepSeek V4 Pro12.670–20; mean of three runs
GPT-6.1 Sol11.670–20; mean of three runs
BTTF0.3670–1; higher is more readable

Views

Source code

package io.netty.microbench.buffer; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledUnsafeDirectByteBuf; import io.netty.microbench.util.AbstractMicrobenchmark; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.TearDown; import java.nio.ByteBuffer; public class UnsafeByteBufBenchmark extends AbstractMicrobenchmark { private ByteBuf unsafeBuffer; private ByteBuffer byteBuffer; @Setup public void setup() { final int a = 32; final int b = 32; final int c = 32; final int d = 32; unsafeBuffer = new UnpooledUnsafeDirectByteBuf(UnpooledByteBufAllocator.DEFAULT, (a + b), (c + d)); final int e = 32; final int f = 32; byteBuffer = ByteBuffer.allocateDirect((e + f)); } @TearDown public void tearDown() { unsafeBuffer.release(); } @Benchmark public long setGetLongUnsafeByteBuf() { final int g = 1; final int h = -1; final int i = 2; final int j = -1; final int k = 1; final int l = -1; return unsafeBuffer.setLong((g + h), (i + j)).getLong((k + l)); } @Benchmark public long setGetLongByteBuffer() { final int m = 1; final int n = -1; final int o = 2; final int p = -1; final int q = 1; final int r = -1; return byteBuffer.putLong((m + n), (o + p)).getLong((q + r)); } @Benchmark public ByteBuf setLongUnsafeByteBuf() { final int s = 1; final int t = -1; final int u = 2; final int v = -1; return unsafeBuffer.setLong((s + t), (u + v)); } @Benchmark public ByteBuffer setLongByteBuffer() { final int w = 1; final int x = -1; final int y = 2; final int z = -1; return byteBuffer.putLong((w + x), (y + z)); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.2864.998−94.545
Source linesThe number of non-empty source lines.72+28.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.488−6.732

Intercept 8.87 + feature contributions = -63.607 (log-odds).
Score = sigmoid(-63.607) = 0.

Score0.816

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.72+1.753
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.71−1.478
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.72−1.231
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.106.959−0.865
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.71.898+0.595
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.112−0.149

Intercept 0.07 + feature contributions = -2.109 (log-odds).
Score = sigmoid(-2.109) = 0.108.

Score0.261
Score41
Run 1

The code is a JMH benchmark with a clear structural separation of setup, teardown, and benchmark methods, which aids organization. However, readability suffers due to numerous single-letter variables (a–z) that obscure intent, despite them representing simple arithmetic (e.g., 1 + -1). The repeated allocation of local variables in each benchmark method is unnecessarily verbose and adds clutter. Nesting is minimal and actions are generally one per line, which is good. Reading flow is natural but hampered by the need to mentally decode variable names. Overall, the code is functional but not exemplary for clarity; giving meaningful names or inline constants would significantly improve it.

Run 2

The code is generally readable with clear structure: a single class with setup, teardown, and four benchmark methods. Each benchmark is short and follows a consistent pattern, aiding readability. However, the code is unnecessarily verbose due to many single-letter variables with simple arithmetic (e.g., 'a + b', 'g + h'), which obscures intent and adds noise. The variable names are not meaningful, making it hard to understand the purpose of the constants. Nesting is minimal, and reading flow is natural, but clarity of intent suffers because the logic seems artificially inflated—likely to prevent JIT optimization, yet this is not explained. Action granularity is mostly one operation per line, which is good, but the excessive variable declarations reduce conciseness. Overall, the code is easy to follow structurally but less readable than it could be due to cryptic variable naming and unnecessary length.

Run 3

The code is structured logically with a clear setup, teardown, and benchmark methods. Import statements are organized and the class follows typical Netty microbenchmark conventions. However, readability is severely reduced by the use of meaningless variable names (a through z) defined in dense blocks. The purpose of variables like 'a + b' or 'c + d' is entirely opaque, making the intent unclear and forcing the reader to perform mental arithmetic. This artificially inflates line count and violates the principle of clarity of intent. While nesting is flat and each line generally performs one action, the disorganized variable naming disrupts the natural reading flow. A reader cannot immediately grasp what buffer sizes or indices are being tested without reverse-engineering the arithmetic.

Run 1

Code Structure: Setup, teardown, and benchmark methods are logically separated, with annotations clearly identifying their roles. Nesting: All methods are flat and easy to scan. Clarity of intent: Method and field names communicate the benchmark purpose, but single-letter variables and unnecessary arithmetic obscure simple capacities, offsets, and values. Code length: Numerous redundant constant declarations substantially inflate otherwise short operations. Action granularity: Declarations generally perform one action per line, although chained write/read calls combine two operations and require extra interpretation. Reading flow: Method ordering is natural and formatting consistent, but repeated declarations interrupt the flow and force readers to mentally evaluate expressions before understanding each benchmark.

Run 2

Code Structure: Setup, teardown, and individual benchmarks are logically separated, with descriptive method names. Nesting: Methods are flat and easy to navigate. Clarity of intent: The benchmark comparison is clear, but single-letter variables and unnecessary arithmetic obscure simple capacities, offsets, and values. Code length: Repeated constant declarations substantially inflate otherwise short operations. Action granularity: Most lines perform one action, though set/get benchmarks chain a write and read in one expression. Reading flow: Consistent formatting and parallel benchmark methods support comparison, but readers must repeatedly resolve trivial expressions to understand the actual operations.

Run 3

Code Structure: Setup, teardown, and individual benchmark methods are logically separated. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive method names and JMH annotations convey the benchmarking purpose, but single-letter variables and artificial arithmetic obscure simple capacities, offsets, and values. Code length: Numerous unnecessary temporary variables make otherwise short operations verbose. Action granularity: Most lines contain one declaration or action, but set/get benchmarks combine writing and reading in chained expressions. Reading flow: The lifecycle-to-benchmark ordering is natural, and paired implementations support comparison; however, repetitive declarations interrupt the flow and force readers to calculate constants mentally. Named constants or direct literals would substantially improve readability.