Sample

int-54d235789937-SRC

Unmodified source class

Lines46

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7730–1; higher is more readable
Dorn0.2260–1; higher is more readable
Mi0.3110–1; higher is more readable
LLOC15Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.660–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() { 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.1323.931−43.69
Source linesThe number of non-empty source lines.46+18.4
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.769−7.153

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

Score0.773

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.46+0.854
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.46−0.635
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
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.97−0.443
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.45.827+0.231
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.095+0.018

Intercept 0.07 + feature contributions = -1.232 (log-odds).
Score = sigmoid(-1.232) = 0.226.

Score0.311
Score15
Run 1

The code is highly readable. Structure is clear: class declaration, fields, setup/teardown, and benchmark methods are logically organized. Nesting is minimal—no deep blocks or conditional complexity. Intent is obvious from method names like setGetLongUnsafeByteBuf, and the benchmark comparison between unsafe and standard byte buffers is easy to grasp. Code length is appropriately concise for the task. Each method performs one action, and the fluent calls (e.g., unsafeBuffer.setLong(0, 1).getLong(0)) are readable despite combining two operations. Reading flow is natural: setup, benchmarks, teardown. Minor deductions: field setup details are slightly repetitive (two buffer initializations), and the teardown only releases one buffer, which could confuse if the other buffer required cleanup. Overall, this is clean, focused benchmark code.

Run 2

The code is well-structured and highly readable. It follows a clear logical organization with setup, teardown, and benchmark methods separated by annotations. Nesting is minimal—only one level for the class and method bodies. Intent is evident: benchmarking direct byte buffer operations. The code is concise, with no unnecessary verbosity. Each benchmark method performs a single action, maintaining solid action granularity. Reading flow is natural, progressing from imports through class declaration to setup, benchmarks, and teardown. Minor deductions could stem from the slightly verbose package and import section, but overall the code is exceptionally clear and maintainable.

Run 3

The code is well-structured with clear separation of concerns: setup/teardown, benchmark methods, and imports. Nesting is minimal, with only one class-level scope. Intent is clear — benchmarking unsafe vs standard byte buffer operations. The methods are concise and focused, each performing a single action per line. Reading flow is logical, grouping related functionality. Minor detractors include slightly verbose naming (e.g., `UnsafeByteBufBenchmark`, `setGetLongUnsafeByteBuf`) and repetitive method names, which reduce readability marginally. Overall, it is highly readable and maintainable.

Run 1

Code Structure: Clearly separates buffer fields, setup, teardown, and individual benchmarks. Nesting: Flat methods with no nested control flow. Clarity of intent: Descriptive method names and JMH annotations make the comparison between buffer implementations obvious; literal values 64, 0, and 1 lack explanatory names. Code length: Compact, with little unnecessary code. Action granularity: Most lines perform one action, though the set/get benchmarks chain writes and reads on a single line. Reading flow: Natural progression from initialization to cleanup and benchmark methods, with parallel implementations aiding comparison. Import grouping and spacing could be slightly cleaner.

Run 2

Code Structure: Clearly separates buffer fields, setup, teardown, and benchmark methods. Nesting: Flat methods with no nested control flow make scanning easy. Clarity of intent: JMH annotations and descriptive method names clearly communicate the comparison between buffer implementations; unexplained literals slightly reduce clarity. Code length: Concise, with little unnecessary code. Action granularity: Most lines perform one action, though the set/get benchmarks chain a write and read on one line; this remains easy to understand. Reading flow: The lifecycle methods precede logically paired benchmarks, creating a natural progression. Import grouping and spacing could be improved slightly.

Run 3

Code Structure: Setup, teardown, and benchmark methods are logically separated, with parallel methods making comparisons easy. Nesting: The code is flat, with no nested control flow. Clarity of intent: JMH annotations and descriptive method names clearly communicate the benchmark purpose; repeated numeric literals lack explanatory names. Code length: Short and focused, with little unnecessary code. Action granularity: Most lines perform one action, although the set/get benchmarks chain a write and read on a single line; this remains easy to understand. Reading flow: Initialization precedes cleanup and benchmark operations in a natural order. Import grouping and spacing could be improved slightly.