Path: blob/master/test/micro/org/openjdk/bench/java/nio/ByteBuffers.java
41161 views
/*1* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package org.openjdk.bench.java.nio;2324import org.openjdk.jmh.annotations.Benchmark;25import org.openjdk.jmh.annotations.BenchmarkMode;26import org.openjdk.jmh.annotations.Fork;27import org.openjdk.jmh.annotations.Measurement;28import org.openjdk.jmh.annotations.Mode;29import org.openjdk.jmh.annotations.OutputTimeUnit;30import org.openjdk.jmh.annotations.Param;31import org.openjdk.jmh.annotations.Scope;32import org.openjdk.jmh.annotations.Setup;33import org.openjdk.jmh.annotations.State;34import org.openjdk.jmh.annotations.Warmup;35import java.nio.*;36import java.util.concurrent.TimeUnit;37import static java.nio.ByteOrder.*;3839/**40* Benchmark for memory access operations on java.nio.Buffer ( and its views )41*42* A large number of variants are covered. The individual benchmarks conform to43* the following convention:44* test(Direct|Heap)(Bulk|Loop)(Get|Put)(Byte|Char|Short|Int|Long|Float|Double)(Swap)?(RO)?45*46* This allows to easily run a subset of particular interest. For example:47* Direct only :- "org.openjdk.bench.java.nio.ByteBuffers.testDirect.*"48* Bulk only :- "org.openjdk.bench.java.nio.ByteBuffers.test.*Bulk.*"49* Loop Put Swapped Views: -50* test(Direct|Heap)(Loop)(Put)Byte(View)+(Swap)+"51*/52@BenchmarkMode(Mode.AverageTime)53@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)54@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)55@OutputTimeUnit(TimeUnit.NANOSECONDS)56@State(Scope.Thread)57@Fork(3)58public class ByteBuffers {5960static final int CARRIER_BYTE_WIDTH = 1;6162@Param({"16", "1024", "131072"})63private int size;6465public byte byteValue;66public char charValue;67public short shortValue;68public int intValue;69public long longValue;70public float floatValue;71public double doubleValue;72public byte[] byteArray;7374public ByteBuffer heapByteBuffer;75public ByteBuffer heapByteBufferRO;76public ByteBuffer directByteBuffer;77public ByteBuffer directByteBufferRO;78public ByteBuffer heapByteBufferSwap;79public ByteBuffer heapByteBufferSwapRO;80public ByteBuffer directByteBufferSwap;81public ByteBuffer directByteBufferSwapRO;8283@Setup84public void setup() {85byteArray = new byte[size / CARRIER_BYTE_WIDTH];8687// explicitly allocated heap carrier buffer88heapByteBuffer = ByteBuffer.allocate(size / CARRIER_BYTE_WIDTH);89heapByteBufferRO = ByteBuffer.allocate(size / CARRIER_BYTE_WIDTH).asReadOnlyBuffer();9091heapByteBufferSwap = ByteBuffer.allocate(size / CARRIER_BYTE_WIDTH).order(LITTLE_ENDIAN);92heapByteBufferSwapRO = ByteBuffer.allocate(size / CARRIER_BYTE_WIDTH).order(LITTLE_ENDIAN).asReadOnlyBuffer();93directByteBuffer = ByteBuffer.allocateDirect(size / CARRIER_BYTE_WIDTH);94directByteBufferRO = ByteBuffer.allocateDirect(size / CARRIER_BYTE_WIDTH).asReadOnlyBuffer();95directByteBufferSwap = ByteBuffer.allocateDirect(size / CARRIER_BYTE_WIDTH).order(LITTLE_ENDIAN);96directByteBufferSwapRO = ByteBuffer.allocateDirect(size / CARRIER_BYTE_WIDTH).order(LITTLE_ENDIAN).asReadOnlyBuffer();97}9899100// -- Heap___101102@Benchmark103public byte[] testHeapBulkPutByte() {104heapByteBuffer.put(0, byteArray);105return byteArray;106}107108@Benchmark109public byte[] testHeapBulkGetByte() {110heapByteBuffer.get(0, byteArray);111return byteArray;112}113114// -- Heap_Byte_Swap_RO115116@Benchmark117public int testHeapLoopGetByteSwapRO() {118int r = 0;119for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=1) {120r += heapByteBufferSwapRO.get(i);121}122return r;123}124125// -- Heap_Byte_Swap_126127@Benchmark128public void testHeapLoopPutByteSwap() {129for (int i = 0; i < heapByteBufferSwap.capacity(); i+=1) {130heapByteBufferSwap.put(i, byteValue);131}132}133134@Benchmark135public int testHeapLoopGetByteSwap() {136int r = 0;137for (int i = 0; i < heapByteBufferSwap.capacity(); i+=1) {138r += heapByteBufferSwap.get(i);139}140return r;141}142143// -- Heap_Byte__RO144145@Benchmark146public int testHeapLoopGetByteRO() {147int r = 0;148for (int i = 0; i < heapByteBufferRO.capacity(); i+=1) {149r += heapByteBufferRO.get(i);150}151return r;152}153154// -- Heap_Byte__155156@Benchmark157public void testHeapLoopPutByte() {158for (int i = 0; i < heapByteBuffer.capacity(); i+=1) {159heapByteBuffer.put(i, byteValue);160}161}162163@Benchmark164public int testHeapLoopGetByte() {165int r = 0;166for (int i = 0; i < heapByteBuffer.capacity(); i+=1) {167r += heapByteBuffer.get(i);168}169return r;170}171172// -- Direct_Byte_Swap_RO173174@Benchmark175public int testDirectLoopGetByteSwapRO() {176int r = 0;177for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=1) {178r += directByteBufferSwapRO.get(i);179}180return r;181}182183// -- Direct_Byte_Swap_184185@Benchmark186public void testDirectLoopPutByteSwap() {187for (int i = 0; i < directByteBufferSwap.capacity(); i+=1) {188directByteBufferSwap.put(i, byteValue);189}190}191192@Benchmark193public int testDirectLoopGetByteSwap() {194int r = 0;195for (int i = 0; i < directByteBufferSwap.capacity(); i+=1) {196r += directByteBufferSwap.get(i);197}198return r;199}200201// -- Direct_Byte__RO202203@Benchmark204public int testDirectLoopGetByteRO() {205int r = 0;206for (int i = 0; i < directByteBufferRO.capacity(); i+=1) {207r += directByteBufferRO.get(i);208}209return r;210}211212// -- Direct_Byte__213214@Benchmark215public void testDirectLoopPutByte() {216for (int i = 0; i < directByteBuffer.capacity(); i+=1) {217directByteBuffer.put(i, byteValue);218}219}220221@Benchmark222public int testDirectLoopGetByte() {223int r = 0;224for (int i = 0; i < directByteBuffer.capacity(); i+=1) {225r += directByteBuffer.get(i);226}227return r;228}229230// -- Heap_Char_Swap_RO231232@Benchmark233public int testHeapLoopGetCharSwapRO() {234int r = 0;235for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=2) {236r += heapByteBufferSwapRO.getChar(i);237}238return r;239}240241// -- Heap_Char_Swap_242243@Benchmark244public void testHeapLoopPutCharSwap() {245for (int i = 0; i < heapByteBufferSwap.capacity(); i+=2) {246heapByteBufferSwap.putChar(i, charValue);247}248}249250@Benchmark251public int testHeapLoopGetCharSwap() {252int r = 0;253for (int i = 0; i < heapByteBufferSwap.capacity(); i+=2) {254r += heapByteBufferSwap.getChar(i);255}256return r;257}258259// -- Heap_Char__RO260261@Benchmark262public int testHeapLoopGetCharRO() {263int r = 0;264for (int i = 0; i < heapByteBufferRO.capacity(); i+=2) {265r += heapByteBufferRO.getChar(i);266}267return r;268}269270// -- Heap_Char__271272@Benchmark273public void testHeapLoopPutChar() {274for (int i = 0; i < heapByteBuffer.capacity(); i+=2) {275heapByteBuffer.putChar(i, charValue);276}277}278279@Benchmark280public int testHeapLoopGetChar() {281int r = 0;282for (int i = 0; i < heapByteBuffer.capacity(); i+=2) {283r += heapByteBuffer.getChar(i);284}285return r;286}287288// -- Direct_Char_Swap_RO289290@Benchmark291public int testDirectLoopGetCharSwapRO() {292int r = 0;293for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=2) {294r += directByteBufferSwapRO.getChar(i);295}296return r;297}298299// -- Direct_Char_Swap_300301@Benchmark302public void testDirectLoopPutCharSwap() {303for (int i = 0; i < directByteBufferSwap.capacity(); i+=2) {304directByteBufferSwap.putChar(i, charValue);305}306}307308@Benchmark309public int testDirectLoopGetCharSwap() {310int r = 0;311for (int i = 0; i < directByteBufferSwap.capacity(); i+=2) {312r += directByteBufferSwap.getChar(i);313}314return r;315}316317// -- Direct_Char__RO318319@Benchmark320public int testDirectLoopGetCharRO() {321int r = 0;322for (int i = 0; i < directByteBufferRO.capacity(); i+=2) {323r += directByteBufferRO.getChar(i);324}325return r;326}327328// -- Direct_Char__329330@Benchmark331public void testDirectLoopPutChar() {332for (int i = 0; i < directByteBuffer.capacity(); i+=2) {333directByteBuffer.putChar(i, charValue);334}335}336337@Benchmark338public int testDirectLoopGetChar() {339int r = 0;340for (int i = 0; i < directByteBuffer.capacity(); i+=2) {341r += directByteBuffer.getChar(i);342}343return r;344}345346// -- Heap_Short_Swap_RO347348@Benchmark349public int testHeapLoopGetShortSwapRO() {350int r = 0;351for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=2) {352r += heapByteBufferSwapRO.getShort(i);353}354return r;355}356357// -- Heap_Short_Swap_358359@Benchmark360public void testHeapLoopPutShortSwap() {361for (int i = 0; i < heapByteBufferSwap.capacity(); i+=2) {362heapByteBufferSwap.putShort(i, shortValue);363}364}365366@Benchmark367public int testHeapLoopGetShortSwap() {368int r = 0;369for (int i = 0; i < heapByteBufferSwap.capacity(); i+=2) {370r += heapByteBufferSwap.getShort(i);371}372return r;373}374375// -- Heap_Short__RO376377@Benchmark378public int testHeapLoopGetShortRO() {379int r = 0;380for (int i = 0; i < heapByteBufferRO.capacity(); i+=2) {381r += heapByteBufferRO.getShort(i);382}383return r;384}385386// -- Heap_Short__387388@Benchmark389public void testHeapLoopPutShort() {390for (int i = 0; i < heapByteBuffer.capacity(); i+=2) {391heapByteBuffer.putShort(i, shortValue);392}393}394395@Benchmark396public int testHeapLoopGetShort() {397int r = 0;398for (int i = 0; i < heapByteBuffer.capacity(); i+=2) {399r += heapByteBuffer.getShort(i);400}401return r;402}403404// -- Direct_Short_Swap_RO405406@Benchmark407public int testDirectLoopGetShortSwapRO() {408int r = 0;409for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=2) {410r += directByteBufferSwapRO.getShort(i);411}412return r;413}414415// -- Direct_Short_Swap_416417@Benchmark418public void testDirectLoopPutShortSwap() {419for (int i = 0; i < directByteBufferSwap.capacity(); i+=2) {420directByteBufferSwap.putShort(i, shortValue);421}422}423424@Benchmark425public int testDirectLoopGetShortSwap() {426int r = 0;427for (int i = 0; i < directByteBufferSwap.capacity(); i+=2) {428r += directByteBufferSwap.getShort(i);429}430return r;431}432433// -- Direct_Short__RO434435@Benchmark436public int testDirectLoopGetShortRO() {437int r = 0;438for (int i = 0; i < directByteBufferRO.capacity(); i+=2) {439r += directByteBufferRO.getShort(i);440}441return r;442}443444// -- Direct_Short__445446@Benchmark447public void testDirectLoopPutShort() {448for (int i = 0; i < directByteBuffer.capacity(); i+=2) {449directByteBuffer.putShort(i, shortValue);450}451}452453@Benchmark454public int testDirectLoopGetShort() {455int r = 0;456for (int i = 0; i < directByteBuffer.capacity(); i+=2) {457r += directByteBuffer.getShort(i);458}459return r;460}461462// -- Heap_Int_Swap_RO463464@Benchmark465public int testHeapLoopGetIntSwapRO() {466int r = 0;467for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=4) {468r += heapByteBufferSwapRO.getInt(i);469}470return r;471}472473// -- Heap_Int_Swap_474475@Benchmark476public void testHeapLoopPutIntSwap() {477for (int i = 0; i < heapByteBufferSwap.capacity(); i+=4) {478heapByteBufferSwap.putInt(i, intValue);479}480}481482@Benchmark483public int testHeapLoopGetIntSwap() {484int r = 0;485for (int i = 0; i < heapByteBufferSwap.capacity(); i+=4) {486r += heapByteBufferSwap.getInt(i);487}488return r;489}490491// -- Heap_Int__RO492493@Benchmark494public int testHeapLoopGetIntRO() {495int r = 0;496for (int i = 0; i < heapByteBufferRO.capacity(); i+=4) {497r += heapByteBufferRO.getInt(i);498}499return r;500}501502// -- Heap_Int__503504@Benchmark505public void testHeapLoopPutInt() {506for (int i = 0; i < heapByteBuffer.capacity(); i+=4) {507heapByteBuffer.putInt(i, intValue);508}509}510511@Benchmark512public int testHeapLoopGetInt() {513int r = 0;514for (int i = 0; i < heapByteBuffer.capacity(); i+=4) {515r += heapByteBuffer.getInt(i);516}517return r;518}519520// -- Direct_Int_Swap_RO521522@Benchmark523public int testDirectLoopGetIntSwapRO() {524int r = 0;525for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=4) {526r += directByteBufferSwapRO.getInt(i);527}528return r;529}530531// -- Direct_Int_Swap_532533@Benchmark534public void testDirectLoopPutIntSwap() {535for (int i = 0; i < directByteBufferSwap.capacity(); i+=4) {536directByteBufferSwap.putInt(i, intValue);537}538}539540@Benchmark541public int testDirectLoopGetIntSwap() {542int r = 0;543for (int i = 0; i < directByteBufferSwap.capacity(); i+=4) {544r += directByteBufferSwap.getInt(i);545}546return r;547}548549// -- Direct_Int__RO550551@Benchmark552public int testDirectLoopGetIntRO() {553int r = 0;554for (int i = 0; i < directByteBufferRO.capacity(); i+=4) {555r += directByteBufferRO.getInt(i);556}557return r;558}559560// -- Direct_Int__561562@Benchmark563public void testDirectLoopPutInt() {564for (int i = 0; i < directByteBuffer.capacity(); i+=4) {565directByteBuffer.putInt(i, intValue);566}567}568569@Benchmark570public int testDirectLoopGetInt() {571int r = 0;572for (int i = 0; i < directByteBuffer.capacity(); i+=4) {573r += directByteBuffer.getInt(i);574}575return r;576}577578// -- Heap_Long_Swap_RO579580@Benchmark581public int testHeapLoopGetLongSwapRO() {582int r = 0;583for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=8) {584r += heapByteBufferSwapRO.getLong(i);585}586return r;587}588589// -- Heap_Long_Swap_590591@Benchmark592public void testHeapLoopPutLongSwap() {593for (int i = 0; i < heapByteBufferSwap.capacity(); i+=8) {594heapByteBufferSwap.putLong(i, longValue);595}596}597598@Benchmark599public int testHeapLoopGetLongSwap() {600int r = 0;601for (int i = 0; i < heapByteBufferSwap.capacity(); i+=8) {602r += heapByteBufferSwap.getLong(i);603}604return r;605}606607// -- Heap_Long__RO608609@Benchmark610public int testHeapLoopGetLongRO() {611int r = 0;612for (int i = 0; i < heapByteBufferRO.capacity(); i+=8) {613r += heapByteBufferRO.getLong(i);614}615return r;616}617618// -- Heap_Long__619620@Benchmark621public void testHeapLoopPutLong() {622for (int i = 0; i < heapByteBuffer.capacity(); i+=8) {623heapByteBuffer.putLong(i, longValue);624}625}626627@Benchmark628public int testHeapLoopGetLong() {629int r = 0;630for (int i = 0; i < heapByteBuffer.capacity(); i+=8) {631r += heapByteBuffer.getLong(i);632}633return r;634}635636// -- Direct_Long_Swap_RO637638@Benchmark639public int testDirectLoopGetLongSwapRO() {640int r = 0;641for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=8) {642r += directByteBufferSwapRO.getLong(i);643}644return r;645}646647// -- Direct_Long_Swap_648649@Benchmark650public void testDirectLoopPutLongSwap() {651for (int i = 0; i < directByteBufferSwap.capacity(); i+=8) {652directByteBufferSwap.putLong(i, longValue);653}654}655656@Benchmark657public int testDirectLoopGetLongSwap() {658int r = 0;659for (int i = 0; i < directByteBufferSwap.capacity(); i+=8) {660r += directByteBufferSwap.getLong(i);661}662return r;663}664665// -- Direct_Long__RO666667@Benchmark668public int testDirectLoopGetLongRO() {669int r = 0;670for (int i = 0; i < directByteBufferRO.capacity(); i+=8) {671r += directByteBufferRO.getLong(i);672}673return r;674}675676// -- Direct_Long__677678@Benchmark679public void testDirectLoopPutLong() {680for (int i = 0; i < directByteBuffer.capacity(); i+=8) {681directByteBuffer.putLong(i, longValue);682}683}684685@Benchmark686public int testDirectLoopGetLong() {687int r = 0;688for (int i = 0; i < directByteBuffer.capacity(); i+=8) {689r += directByteBuffer.getLong(i);690}691return r;692}693694// -- Heap_Float_Swap_RO695696@Benchmark697public int testHeapLoopGetFloatSwapRO() {698int r = 0;699for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=4) {700r += heapByteBufferSwapRO.getFloat(i);701}702return r;703}704705// -- Heap_Float_Swap_706707@Benchmark708public void testHeapLoopPutFloatSwap() {709for (int i = 0; i < heapByteBufferSwap.capacity(); i+=4) {710heapByteBufferSwap.putFloat(i, floatValue);711}712}713714@Benchmark715public int testHeapLoopGetFloatSwap() {716int r = 0;717for (int i = 0; i < heapByteBufferSwap.capacity(); i+=4) {718r += heapByteBufferSwap.getFloat(i);719}720return r;721}722723// -- Heap_Float__RO724725@Benchmark726public int testHeapLoopGetFloatRO() {727int r = 0;728for (int i = 0; i < heapByteBufferRO.capacity(); i+=4) {729r += heapByteBufferRO.getFloat(i);730}731return r;732}733734// -- Heap_Float__735736@Benchmark737public void testHeapLoopPutFloat() {738for (int i = 0; i < heapByteBuffer.capacity(); i+=4) {739heapByteBuffer.putFloat(i, floatValue);740}741}742743@Benchmark744public int testHeapLoopGetFloat() {745int r = 0;746for (int i = 0; i < heapByteBuffer.capacity(); i+=4) {747r += heapByteBuffer.getFloat(i);748}749return r;750}751752// -- Direct_Float_Swap_RO753754@Benchmark755public int testDirectLoopGetFloatSwapRO() {756int r = 0;757for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=4) {758r += directByteBufferSwapRO.getFloat(i);759}760return r;761}762763// -- Direct_Float_Swap_764765@Benchmark766public void testDirectLoopPutFloatSwap() {767for (int i = 0; i < directByteBufferSwap.capacity(); i+=4) {768directByteBufferSwap.putFloat(i, floatValue);769}770}771772@Benchmark773public int testDirectLoopGetFloatSwap() {774int r = 0;775for (int i = 0; i < directByteBufferSwap.capacity(); i+=4) {776r += directByteBufferSwap.getFloat(i);777}778return r;779}780781// -- Direct_Float__RO782783@Benchmark784public int testDirectLoopGetFloatRO() {785int r = 0;786for (int i = 0; i < directByteBufferRO.capacity(); i+=4) {787r += directByteBufferRO.getFloat(i);788}789return r;790}791792// -- Direct_Float__793794@Benchmark795public void testDirectLoopPutFloat() {796for (int i = 0; i < directByteBuffer.capacity(); i+=4) {797directByteBuffer.putFloat(i, floatValue);798}799}800801@Benchmark802public int testDirectLoopGetFloat() {803int r = 0;804for (int i = 0; i < directByteBuffer.capacity(); i+=4) {805r += directByteBuffer.getFloat(i);806}807return r;808}809810// -- Heap_Double_Swap_RO811812@Benchmark813public int testHeapLoopGetDoubleSwapRO() {814int r = 0;815for (int i = 0; i < heapByteBufferSwapRO.capacity(); i+=8) {816r += heapByteBufferSwapRO.getDouble(i);817}818return r;819}820821// -- Heap_Double_Swap_822823@Benchmark824public void testHeapLoopPutDoubleSwap() {825for (int i = 0; i < heapByteBufferSwap.capacity(); i+=8) {826heapByteBufferSwap.putDouble(i, doubleValue);827}828}829830@Benchmark831public int testHeapLoopGetDoubleSwap() {832int r = 0;833for (int i = 0; i < heapByteBufferSwap.capacity(); i+=8) {834r += heapByteBufferSwap.getDouble(i);835}836return r;837}838839// -- Heap_Double__RO840841@Benchmark842public int testHeapLoopGetDoubleRO() {843int r = 0;844for (int i = 0; i < heapByteBufferRO.capacity(); i+=8) {845r += heapByteBufferRO.getDouble(i);846}847return r;848}849850// -- Heap_Double__851852@Benchmark853public void testHeapLoopPutDouble() {854for (int i = 0; i < heapByteBuffer.capacity(); i+=8) {855heapByteBuffer.putDouble(i, doubleValue);856}857}858859@Benchmark860public int testHeapLoopGetDouble() {861int r = 0;862for (int i = 0; i < heapByteBuffer.capacity(); i+=8) {863r += heapByteBuffer.getDouble(i);864}865return r;866}867868// -- Direct_Double_Swap_RO869870@Benchmark871public int testDirectLoopGetDoubleSwapRO() {872int r = 0;873for (int i = 0; i < directByteBufferSwapRO.capacity(); i+=8) {874r += directByteBufferSwapRO.getDouble(i);875}876return r;877}878879// -- Direct_Double_Swap_880881@Benchmark882public void testDirectLoopPutDoubleSwap() {883for (int i = 0; i < directByteBufferSwap.capacity(); i+=8) {884directByteBufferSwap.putDouble(i, doubleValue);885}886}887888@Benchmark889public int testDirectLoopGetDoubleSwap() {890int r = 0;891for (int i = 0; i < directByteBufferSwap.capacity(); i+=8) {892r += directByteBufferSwap.getDouble(i);893}894return r;895}896897// -- Direct_Double__RO898899@Benchmark900public int testDirectLoopGetDoubleRO() {901int r = 0;902for (int i = 0; i < directByteBufferRO.capacity(); i+=8) {903r += directByteBufferRO.getDouble(i);904}905return r;906}907908// -- Direct_Double__909910@Benchmark911public void testDirectLoopPutDouble() {912for (int i = 0; i < directByteBuffer.capacity(); i+=8) {913directByteBuffer.putDouble(i, doubleValue);914}915}916917@Benchmark918public int testDirectLoopGetDouble() {919int r = 0;920for (int i = 0; i < directByteBuffer.capacity(); i+=8) {921r += directByteBuffer.getDouble(i);922}923return r;924}925}926927928