Sample

int-fa39faa54d6c-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines46

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6820–1; higher is more readable
Dorn0.2010–1; higher is more readable
Mi0.2010–1; higher is more readable
LLOC15Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6310–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, 0x40, 0x40); byteBuffer = ByteBuffer.allocateDirect(0x40); } @TearDown public void tearDown() { unsafeBuffer.release(); } @Benchmark public long setGetLongUnsafeByteBuf() { return unsafeBuffer.setLong(0x0, 0x1).getLong(0x0); } @Benchmark public long setGetLongByteBuffer() { return byteBuffer.putLong(0x0, 0x1).getLong(0x0); } @Benchmark public ByteBuf setLongUnsafeByteBuf() { return unsafeBuffer.setLong(0x0, 0x1); } @Benchmark public ByteBuffer setLongByteBuffer() { return byteBuffer.putLong(0x0, 0x1); } }

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.1405.38−46.378
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.808−7.212

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

Score0.682

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
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.100.936−0.61
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.45.784+0.23
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.093+0.037

Intercept 0.07 + feature contributions = -1.379 (log-odds).
Score = sigmoid(-1.379) = 0.201.

Score0.201
Score15
Run 1

The code is highly readable with clear structure and purpose. It follows standard Java conventions, has minimal nesting, and uses descriptive names. The benchmark methods are concise, each performing a single logical action. However, the reliance on hexadecimal literals without named constants slightly reduces clarity of intent, and the mixed return types (long vs ByteBuf/ByteBuffer) across similar benchmark methods could be improved for consistency.

Run 2

The code is well-structured with clear separation of setup, teardown, and benchmark methods. Imports are organized and the class has a single responsibility. Nesting is minimal and there is no unnecessary complexity. Intent is evident from method names and benchmark annotations. The code is concise for what it tests, with each benchmark method performing one logical action. Action granularity is appropriate, with each line representing a single operation. Reading flow is natural, moving from setup to benchmarks. Minor deductions: inconsistent return types for similar operations (long vs ByteBuf/ByteBuffer) slightly reduce clarity, and magic numbers (0x40, 0x0, 0x1) could use named constants for better readability.

Run 3

The code is well-structured and highly readable. It follows a clean, logical organization with imports, class declaration, fields, and setup/teardown methods clearly separated. Nesting is minimal—methods are flat and focused. Intent is clear: this is a JMH benchmark comparing unsafe ByteBuf operations against standard ByteBuffer. The code is concise without unnecessary boilerplate, though a blank line between imports and class declaration would improve formatting slightly. Each benchmark method performs one logical action per line, either setting and getting or just setting a long. Reading flow is natural: setup, benchmarks, teardown in expected order. The only minor readability concern is the repetitive method names, which are descriptive but slightly verbose. Overall, the code demonstrates excellent readability with clear purpose, consistent naming, and appropriate use of annotations.

Run 1

Code Structure: Setup, teardown, and benchmark methods are logically separated, with related buffer operations paired. Nesting: Methods are flat and have no conditional or loop nesting. Clarity of intent: Descriptive method names and JMH annotations clearly identify the benchmark purpose; repeated hexadecimal literals would be clearer as named constants. Code length: The class is concise, with minimal boilerplate and no unnecessary logic. Action granularity: Most lines perform one action, although the set/get benchmarks chain two operations on a single line. Reading flow: Initialization precedes cleanup and benchmarks, creating a natural progression. Missing spacing between the package and imports and inconsistent import grouping slightly reduce polish.

Run 2

Code Structure: Fields, setup, teardown, and benchmark methods are logically organized and clearly separated. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive method names and JMH annotations make the benchmark purpose clear; unexplained hexadecimal literals slightly reduce clarity. Code length: The implementation is concise, with little unnecessary code. Action granularity: Most statements perform one action, although the set/get benchmarks chain two operations on one line. Reading flow: Consistent formatting and parallel benchmark methods make comparisons easy; grouping imports and naming the repeated capacity value would improve readability.

Run 3

Code Structure: Fields, setup, teardown, and benchmark methods are logically organized with clear separation of responsibilities. Nesting: The code is flat, with no nested control flow. Clarity of intent: Descriptive method names and JMH annotations clearly communicate the benchmark purpose; unexplained hexadecimal literals slightly reduce clarity. Code length: The class is concise, with minimal boilerplate and no unnecessary logic. Action granularity: Most lines perform one action, although the set/get benchmarks chain a write and read on a single line. Reading flow: Consistent formatting and parallel benchmark methods make comparison natural; import grouping and named constants could improve readability further.