Sample

int-74b9afe9f2ad-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7490–1; higher is more readable
Dorn0.1960–1; higher is more readable
Mi0.3110–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro13.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.5130–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() { unsafeBuffer = new UnpooledUnsafeDirectByteBuf(UnpooledByteBufAllocator.DEFAULT, 64, 64); byteBuffer = ByteBuffer.allocateDirect(64); } @TearDown public void tearDown() { unsafeBuffer.release(); } @Benchmark public long setGetLongUnsafeByteBuf() { return unsafeBuffer.setLong(0, 1).getLong(0); } @Benchmark public long setGetLongByteBuffer() { { int runningTotal = 0; for (int currentNumber = 1; currentNumber <= 5; currentNumber++) { runningTotal += currentNumber; } } return byteBuffer.putLong(0, 1).getLong(0); } @Benchmark public ByteBuf setLongUnsafeByteBuf() { return unsafeBuffer.setLong(0, 1); } @Benchmark public ByteBuffer setLongByteBuffer() { return byteBuffer.putLong(0, 1); } }

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.1530.184−50.496
Source linesThe number of non-empty source lines.53+21.2
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.793−7.189

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

Score0.749

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.53−0.84
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
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.96.981−0.443
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.827+0.329
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.099−0.023

Intercept 0.07 + feature contributions = -1.411 (log-odds).
Score = sigmoid(-1.411) = 0.196.

Score0.311
Score19
Run 1

The code has a clear structure with meaningful method names and proper annotations, but readability is severely compromised by a misplaced, irrelevant block of code inside setGetLongByteBuffer(). This block—a loop with unrelated variables—has no connection to the benchmark's purpose and interrupts the natural reading flow. Additionally, the class is missing an import for UnpooledByteBufAllocator's DEFAULT constant? (Actually it is imported correctly.) The main issues are the stray code block and slightly inconsistent formatting. Otherwise, the benchmark methods are concise and demonstrate reasonable separation of concerns.

Run 2

The code is mostly straightforward but has significant readability issues. There is an erroneous nested block inside setGetLongByteBuffer() that computes a running total but is unrelated to the method's purpose, creating confusion. The code structure is logical but the stray block disrupts clarity of intent. Nesting is minimal, which is good. Action granularity is appropriate—one action per line in most places. Reading flow is natural except for the unrelated block. Code length is concise, but the misplaced block makes it unnecessarily longer and ambiguous. With cleanup, it would be highly readable.

Run 3

The code is generally well-structured and readable, with clear class naming and separation of benchmark methods. However, there is a significant error in the setGetLongByteBuffer method: a random block of code computing a running total is inserted, which is unrelated to the method's purpose and breaks the reading flow. This will cause a compilation error and strongly impacts clarity. Apart from that, the overall structure is logical, nesting is minimal, and methods are concise with one action per line. The imports and annotations are straightforward. The presence of the erroneous code block prevents a higher score despite otherwise clean organization.

Run 1

Code Structure: Setup, teardown, and benchmark methods are logically separated, but an unrelated summation block disrupts one benchmark. Nesting: Mostly flat, with an unnecessary block and loop adding localized nesting. Clarity of intent: Method names and annotations clearly communicate the benchmark comparisons; the unused runningTotal calculation has no apparent purpose. Code length: Generally concise, though the summation block adds needless code. Action granularity: Most lines perform one action, but chained write/read calls combine two operations, reasonably matching the benchmark intent. Reading flow: Consistent method patterns make the class easy to scan, but the summation block's inconsistent indentation and irrelevant logic interrupt that flow.

Run 2

Code Structure: Setup, teardown, and benchmark methods are logically separated, but an unrelated summation block disrupts one benchmark. Nesting: Mostly flat, with an unnecessary block and nested loop in setGetLongByteBuffer. Clarity of intent: Descriptive method names and JMH annotations make the benchmark purpose clear; the unused runningTotal calculation is unexplained and obscures the comparison. Code length: Generally concise, though the summation adds unnecessary lines. Action granularity: Most lines perform one action; chained write/read calls combine operations but remain understandable. Reading flow: Consistent method organization supports natural reading, while the summation block's inconsistent indentation and irrelevant logic interrupt it.

Run 3

Code Structure: Setup, teardown, and benchmark methods are logically separated, but an unrelated summation block disrupts one benchmark. Nesting: Most methods are flat; the extra block and loop introduce unnecessary nesting. Clarity of intent: Method names and annotations clearly identify benchmark operations, while the unused runningTotal calculation has no apparent purpose. Code length: Generally concise, except for the irrelevant loop. Action granularity: Most lines perform one action; chained write/read calls combine two operations but remain understandable. Reading flow: Consistent benchmark naming and ordering support natural reading, but the poorly indented inserted block sharply interrupts the flow.