Search in sources :

Example 11 with User

use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.

the class MapVsThreadLocalBenchmark method directGet.

@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public User directGet() {
    User user = directUser;
    if (user != null && user.getId() == 12345L) {
        return user;
    }
    user = userService.getUser(12345L).join();
    directUser = 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 12 with User

use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.

the class KryoByteBufTest method main.

public static void main(String[] args) {
    Kryo kryo = new Kryo();
    // kryo.setWarnUnregisteredClasses(true);
    // kryo.setReferences(false);
    kryo.register(IntObj.class);
    kryo.register(StringUTF8Obj.class);
    kryo.register(LocalDateTimeObj.class);
    kryo.register(ComplexObj.class);
    kryo.register(int[].class);
    kryo.register(ArrayList.class);
    kryo.register(ArrayListObj.class);
    ByteBufAllocator allocator = new PooledByteBufAllocator(true);
    ByteBuf buffer = allocator.directBuffer(2, 1024 * 1024 * 8);
    System.out.println("buffer.nioBufferCount: " + buffer.nioBufferCount());
    System.out.println(buffer.nioBuffer(0, buffer.capacity()));
    ByteBufOutput output = new ByteBufOutput(buffer);
    UserService userService = new UserServiceServerImpl();
    User user = userService.getUser(Long.MAX_VALUE).join();
    while (true) {
        buffer.clear();
        output.setBuffer(buffer);
        kryo.writeObject(output, user);
        ByteBufInput input = new ByteBufInput(buffer);
        User u = kryo.readObject(input, User.class);
        System.out.println(u);
    }
// buffer.clear();
// output.setBuffer(buffer);
// kryo.writeObject(output, user);
// System.out.println("user writeObject: " + output.total());
// 
// ByteBufInput input = new ByteBufInput(buffer);
// System.out.println("user readableBytes: " + buffer.readableBytes());
// System.out.println("user readerIndex: " + buffer.readerIndex());
// System.out.println(kryo.readObject(input, User.class));
}
Also used : ByteBufAllocator(io.netty.buffer.ByteBufAllocator) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) UserServiceServerImpl(rpc.turbo.benchmark.service.UserServiceServerImpl) User(rpc.turbo.benchmark.bean.User) ByteBufOutput(rpc.turbo.serialization.kryo.ByteBufOutput) UserService(rpc.turbo.benchmark.service.UserService) ByteBufInput(rpc.turbo.serialization.kryo.ByteBufInput) ByteBuf(io.netty.buffer.ByteBuf) Kryo(com.esotericsoftware.kryo.Kryo) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator)

Example 13 with User

use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.

the class AbstractClient method createUser.

public Object createUser() throws Exception {
    int id = counter.getAndIncrement();
    User user = _serviceUserService.getUser(id).join();
    return getUserService().createUser(user).join();
}
Also used : User(rpc.turbo.benchmark.bean.User)

Example 14 with User

use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.

the class TruboClientBootTest method test.

@PostConstruct
public void test() {
    System.out.println(Arrays.toString(applicationContext.getBeanNamesForType(UserService.class)));
    System.out.println("userService: " + userService.getClass().getName());
    System.out.println("userService2: " + userService2.getClass().getName());
    System.out.println("existUser:");
    boolean existUser = userService.existUser("hank.whu@gmail.com").join();
    System.out.println(existUser);
    System.out.println("=====================");
    System.out.println();
    System.out.println("getUser:");
    User user = userService.getUser(1).join();
    System.out.println(user);
    System.out.println("=====================");
    System.out.println();
    System.out.println("createUser:");
    System.out.println(userService2.createUser(user).join());
    System.out.println("=====================");
    System.out.println();
    System.out.println("listUser:");
    System.out.println(userService.listUser(1).join());
    System.out.println("=====================");
    System.out.println();
}
Also used : User(rpc.turbo.benchmark.bean.User) PostConstruct(javax.annotation.PostConstruct)

Example 15 with User

use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.

the class UserServiceServerImpl method getUser.

@Override
public CompletableFuture<User> getUser(long id) {
    user = new User();
    user.setId(id);
    user.setName("Doug Lea");
    user.setSex(1);
    user.setBirthday(LocalDate.of(1968, 12, 8));
    user.setEmail("dong.lea@gmail.com");
    user.setMobile("18612345678");
    user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605");
    user.setIcon("https://www.baidu.com/img/bd_logo1.png");
    user.setStatus(1);
    user.setCreateTime(LocalDateTime.now());
    user.setUpdateTime(user.getCreateTime());
    List<Integer> permissions = new ArrayList<>(List.of(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92));
    user.setPermissions(permissions);
    return CompletableFuture.completedFuture(user);
}
Also used : User(rpc.turbo.benchmark.bean.User) ArrayList(java.util.ArrayList)

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