use of com.weibo.api.motan.protocol.rpc.DefaultRpcCodec in project motan by weibocom.
the class DefaultRpcCodecTest method main.
public static void main(String[] args) throws Exception {
DefaultRpcCodec codec = new DefaultRpcCodec();
MockChannel channel = new MockChannel(new URL("motan", "localhost", 18080, IHello.class.getName()));
System.out.println("requestSize: " + requestSize(codec, channel, null).length);
System.out.println("responseSize: " + responseSize(codec, channel, null).length);
System.out.println("responseSize: " + exceptionResponseSize(codec, channel).length);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 200; i++) {
builder.append("1");
}
String value = builder.toString();
String[] arr = new String[] { value, value, value };
Long[] sets = new Long[20];
for (int i = 0; i < 20; i++) {
sets[i] = 1000000000L + i;
}
System.out.println("requestSize 1k: " + requestSize(codec, channel, arr).length);
System.out.println("responseSize 1k: " + responseSize(codec, channel, arr).length);
byte[] data = null;
for (int i = 0; i < loop; i++) {
data = requestSize(codec, channel, sets);
codec.decode(channel, "", data);
}
long start = System.nanoTime();
for (int i = 0; i < loop; i++) {
data = requestSize(codec, channel, sets);
}
System.out.println("request encode performance: " + (System.nanoTime() - start) / loop + " ns");
start = System.nanoTime();
for (int i = 0; i < loop; i++) {
codec.decode(channel, "", data);
}
System.out.println("request decode performance: " + (System.nanoTime() - start) / loop + " ns");
}
Aggregations