| 1 |
/* |
| 2 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 |
* you may not use this file except in compliance with the License. |
| 4 |
* You may obtain a copy of the License at |
| 5 |
* |
| 6 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
* |
| 8 |
* Unless required by applicable law or agreed to in writing, software |
| 9 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
* See the License for the specific language governing permissions and |
| 12 |
* limitations under the License. |
| 13 |
*/ |
| 14 |
package io.airlift.slice; |
| 15 |
|
| 16 |
import org.openjdk.jmh.annotations.Param; |
| 17 |
import org.openjdk.jmh.annotations.Scope; |
| 18 |
import org.openjdk.jmh.annotations.Setup; |
| 19 |
import org.openjdk.jmh.annotations.State; |
| 20 |
|
| 21 |
import java.util.concurrent.ThreadLocalRandom; |
| 22 |
|
| 23 |
@State(Scope.Thread) |
| 24 |
public class BenchmarkData |
| 25 |
{ |
| 26 |
@Param({"1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768", "65536", "131072", "262144", "524288", "1048576"}) |
| 27 |
public int size; |
| 28 |
|
| 29 |
private byte[] bytes; |
| 30 |
private Slice slice; |
| 31 |
|
| 32 |
@Setup |
| 33 |
public void setup() |
| 34 |
{ |
| 35 |
bytes = new byte[size]; |
| 36 |
ThreadLocalRandom.current().nextBytes(bytes); |
| 37 |
slice = Slices.wrappedBuffer(bytes); |
| 38 |
} |
| 39 |
|
| 40 |
public Slice getSlice() |
| 41 |
{ |
| 42 |
return slice; |
| 43 |
} |
| 44 |
|
| 45 |
public byte[] getBytes() |
| 46 |
{ |
| 47 |
return bytes; |
| 48 |
} |
| 49 |
} |