本文整理匯總了Java中org.openjdk.jmh.annotations.Mode.Throughput方法的典型用法代碼示例。如果您正苦於以下問題:Java Mode.Throughput方法的具體用法?Java Mode.Throughput怎麽用?Java Mode.Throughput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openjdk.jmh.annotations.Mode
的用法示例。
在下文中一共展示了Mode.Throughput方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendAsyncMessage
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
/**
* 發送異步消息
* @throws InterruptedException
* @throws RemotingException
* @throws MQClientException
* @throws MQBrokerException
*/
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendAsyncMessage() throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
producer.send(new Message(RocketMQConfiguration.ROCKETMQ_TOPIC,message), new SendCallback() {
@Override
public void onSuccess(SendResult sendResult) {
//System.out.println("receive message"+sendResult);
}
@Override
public void onException(Throwable throwable) {
//System.out.println("receive message error"+throwable.getLocalizedMessage());
}
});
}
示例2: testUnfairLockContended
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode({ Mode.Throughput})
@OutputTimeUnit
(TimeUnit.MILLISECONDS)
public long testUnfairLockContended(Contended contended )
{
contended.unfairLock.lock();
try{
return execute();
}
finally
{
contended.unfairLock.unlock();
}
}
示例3: testFairLockContended
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode({ Mode.Throughput})
@OutputTimeUnit
(TimeUnit.MILLISECONDS)
public long testFairLockContended(Contended contended)
{
contended.fairLock.lock();
try{
return execute();
}
finally
{
contended.fairLock.unlock();
}
}
示例4: testApi
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@OperationsPerInvocation(10000)
public void testApi() {
Map<String, Object> data = new HashMap<String, Object>();
data.put("encryptKey", "0000000000000000");
data.put("barcode", "LH10312ACCF23C4F3A5");
Multimap<String, Rule> rules = ArrayListMultimap.create();
rules.put("barcode", Rule.required());
rules.put("barcode", Rule.regex("[0-9A-F]{16}"));
rules.put("encryptKey", Rule.required());
rules.put("encryptKey", Rule.regex("LH[0-7][0-9a-fA-F]{2}[0-5][0-4][0-9a-fA-F]{12}"));
try {
Validations.validate(data, rules);
} catch (Exception e) {
}
}
示例5: testWithGMP
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testWithGMP(PaillierBenchmarkState allState)
{
SystemConfiguration.setProperty("paillier.useGMPForModPow", "true");
SystemConfiguration.setProperty("paillier.GMPConstantTimeMode", "false");
ModPowAbstraction.reloadConfiguration();
try
{
allState.pallier.encrypt(allState.m1, allState.r1);
} catch (PIRException e)
{
logger.info("Exception in testWithGMP!\n");
}
}
示例6: testWithGMPConstantTime
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testWithGMPConstantTime(PaillierBenchmarkState allState)
{
SystemConfiguration.setProperty("paillier.useGMPForModPow", "true");
SystemConfiguration.setProperty("paillier.GMPConstantTimeMode", "true");
ModPowAbstraction.reloadConfiguration();
try
{
allState.pallier.encrypt(allState.m1, allState.r1);
} catch (PIRException e)
{
logger.info("Exception in testWithGMPConstantTime!\n");
}
}
示例7: benchmark
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void benchmark(final AdditionalCounters counters) throws Exception {
JsonRequest<Ping> request = new JsonRequest.Builder<Ping>("ping-server", "ping")
.setBody(new Ping("ping?"))
.setTimeout(20000)
.setRetryLimit(0)
.build();
TFuture<JsonResponse<Pong>> future = this.subClient.send(request);
future.addCallback(new TFutureCallback<JsonResponse<Pong>>() {
@Override
public void onResponse(JsonResponse<Pong> pongResponse) {
if (!pongResponse.isError()) {
counters.actualQPS.incrementAndGet();
} else {
counters.errorQPS.incrementAndGet();
}
}
});
}
示例8: timeMergeAndBuild
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime, Mode.SingleShotTime})
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Measurement(iterations = ITERATIONS_COUNT, time = 1000, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public Message timeMergeAndBuild() {
dummy = ++dummy % Integer.MAX_VALUE;
Builder builder = newBuilder(expectedMessage)
.getFieldBuilder(galaxyStar, 0)
.setField(starName, String.valueOf(dummy))
.mergeFrom(mergeStar1Message)
.getFieldBuilder(starPlanet, 0)
.mergeFrom(mergePlanet1Message)
.toParent()
.toParent();
return builder.build();
}
示例9: timeMergeAndBuildOriginalGM
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime, Mode.SingleShotTime})
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Measurement(iterations = ITERATIONS_COUNT, time = 1000, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public Galaxy timeMergeAndBuildOriginalGM() {
dummy = ++dummy % Integer.MAX_VALUE;
Galaxy.Builder builder = Galaxy.newBuilder((Galaxy) expectedMessage);
builder.getStarBuilder(0)
.setName(String.valueOf(dummy))
.mergeFrom(mergeStar1Message)
.getPlanetBuilder(0)
.mergeFrom(mergePlanet1Message);
return builder.build();
}
示例10: testEmptyOptsHaveCompileCommandFile
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Test
public void testEmptyOptsHaveCompileCommandFile() {
Runner blade = new Runner(new OptionsBuilder());
BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, 1, 1,
new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1),
new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1),
Mode.Throughput, null, TimeUnit.SECONDS, 1,
Utils.getCurrentJvm(), Collections.<String>emptyList(),
TimeValue.days(1));
String[] command = blade.getSeparateExecutionCommand(bp, DUMMY_HOST, DUMMY_PORT, Collections.<String>emptyList(), Collections.<String>emptyList());
// expecting 1 compile command file
List<String> files = CompilerHints.getCompileCommandFiles(Arrays.asList(command));
assertEquals(1, files.size());
// file should exist
final String hintFileName = files.get(0);
File hintsFile = new File(hintFileName);
assertTrue(hintsFile.exists());
// hints should be the default as none were specified
Set<String> hints = CompilerHints.fromFile(hintFileName).get();
assertEquals(hints, defaultHints);
}
示例11: sendMessage
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
/**
* 發送同步消息
* @throws InterruptedException
* @throws RemotingException
* @throws MQClientException
* @throws MQBrokerException
*/
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendMessage(){
try {
SendResult sendResult = producer.send(new Message(RocketMQConfiguration.ROCKETMQ_TOPIC, message));
} catch (Exception e) {
//e.printStackTrace();
}
}
示例12: testCascadedValidation
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1)
@Threads(1)
@Warmup(iterations = 5)
@Measurement(iterations = 20)
public void testCascadedValidation(ParsingBeansSpeedState state, Blackhole bh) {
// Validator in new factory
for ( Object o : state.holder.beans ) {
bh.consume( state.validator.getConstraintsForClass( o.getClass() ).isBeanConstrained() );
}
}
示例13: testCascadedValidation
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@Fork(value = 1)
@Threads(50)
@Warmup(iterations = 20) // it seems that as there are a lot of beans it takes some time to warmup
@Measurement(iterations = 30)
public void testCascadedValidation(RawValidationSpeedState state, Blackhole bh) {
for ( Object o : state.holder.beans ) {
Set<ConstraintViolation<Object>> constraintViolations = state.validator.validate( o );
bh.consume( constraintViolations );
}
}
示例14: sendMessage
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendMessage(){
try {
Message msg = new Message(new String(MESSAGE_BYTES));
//msg.setTopic(ZbusConfiguration.topicName);
Message message = producer.sendSync(msg);
//producer.sendAsync(msg);
}catch (Exception e){
e.printStackTrace();
}
}
示例15: testSingleSearch
import org.openjdk.jmh.annotations.Mode; //導入方法依賴的package包/類
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public List<String> testSingleSearch(Data data, Iterator i) {
String query = null;
while(query == null) {
query = i.getNextQuery(data.queries);
}
return data.wordSearch.findSimilarWords(query);
}