Search in sources :

Example 1 with User

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);
    }
}
Also used : User(rpc.turbo.benchmark.bean.User) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) IOException(java.io.IOException)

Example 2 with User

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;
}
Also used : User(rpc.turbo.benchmark.bean.User) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 3 with 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;
}
Also used : User(rpc.turbo.benchmark.bean.User) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 4 with 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;
}
Also used : User(rpc.turbo.benchmark.bean.User) ByteBufInput(io.protostuff.ByteBufInput) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 5 with 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;
}
Also used : User(rpc.turbo.benchmark.bean.User) ByteBufInput(io.protostuff.ByteBufInput) Page(rpc.turbo.benchmark.bean.Page) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

User (rpc.turbo.benchmark.bean.User)15 Benchmark (org.openjdk.jmh.annotations.Benchmark)7 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)7 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)7 ArrayList (java.util.ArrayList)3 ByteBufInput (io.protostuff.ByteBufInput)2 Kryo (com.esotericsoftware.kryo.Kryo)1 ByteBuf (io.netty.buffer.ByteBuf)1 ByteBufAllocator (io.netty.buffer.ByteBufAllocator)1 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 IOException (java.io.IOException)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 RandomAccess (java.util.RandomAccess)1 PostConstruct (javax.annotation.PostConstruct)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1 Page (rpc.turbo.benchmark.bean.Page)1 UserService (rpc.turbo.benchmark.service.UserService)1 UserServiceServerImpl (rpc.turbo.benchmark.service.UserServiceServerImpl)1