use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class UserServiceJsonHttpClientImpl method getUser.
@Override
public CompletableFuture<User> getUser(long id) {
try {
String url = URL_GET_USER + id;
HttpGet request = new HttpGet(url);
CloseableHttpResponse response = client.execute(request);
byte[] bytes = EntityUtils.toByteArray(response.getEntity());
return CompletableFuture.completedFuture(objectMapper.readValue(bytes, User.class));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class MapVsThreadLocalBenchmark method volatileGet.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public User volatileGet() {
User user = volatileUser;
if (user != null && user.getId() == 12345L) {
return user;
}
user = userService.getUser(12345L).join();
volatileUser = user;
return user;
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class MapVsThreadLocalBenchmark method concurrentHashMap.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public User concurrentHashMap() {
User user = userConcurrentMap.get(12345);
if (user != null) {
return user;
}
user = userService.getUser(12345L).join();
userConcurrentMap.put(12345, user);
return user;
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class ProtostuffBenchmark method deserializeUser.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public User deserializeUser() throws Exception {
userBuffer.readerIndex(0);
ByteBufInput input = new ByteBufInput(userBuffer, true);
User user = userSchema.newMessage();
userSchema.mergeFrom(input, user);
return user;
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class ProtostuffBenchmark method deserializeUserPage.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public Page<User> deserializeUserPage() throws Exception {
listBuffer.readerIndex(0);
ByteBufInput input = new ByteBufInput(listBuffer, true);
Page<User> userPage = (Page<User>) userPageSchema.newMessage();
userPageSchema.mergeFrom(input, userPage);
return userPage;
}
Aggregations