public static void benchmark(string msg, IGM test) { Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < 1000 * 10; i++) { test.getBestPlayer(); } Utils.log_debug("{0} elapsed: {1}ms", msg, sw.ElapsedMilliseconds); }
public static void run() { // 多消费者、单生产者的服务模式 IUserContext userContext = ProducerExecutor.newServiceInterface <IUserContext>(new UserContextImpl()); UserInfo userInfo = userContext.getUserInfo(88); Utils.log_debug("stage-100 id={0} name={1}, age={2}", userInfo.id, userInfo.name, userInfo.age); IGM gm = ProducerExecutor.newServiceInterface <IGM>(new GMImpl()); Utils.log_debug("best player id={0}", gm.getBestPlayer()); benchmark("proxied benchmark:", gm); gm = new GMImpl(); benchmark("raw benchmark:", gm); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); Environment.Exit(0); }