DoubleArrayCalls.java revision 169:fa4df2d26d9b
162053Smarkm/* 2255362Smarkm * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. 362053Smarkm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 462053Smarkm * 562053Smarkm * This code is free software; you can redistribute it and/or modify it 662053Smarkm * under the terms of the GNU General Public License version 2 only, as 762053Smarkm * published by the Free Software Foundation. 862053Smarkm * 962053Smarkm * This code is distributed in the hope that it will be useful, but WITHOUT 1062053Smarkm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1162053Smarkm * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1262053Smarkm * version 2 for more details (a copy is included in the LICENSE file that 1362053Smarkm * accompanied this code). 1462053Smarkm * 1562053Smarkm * You should have received a copy of the GNU General Public License version 1662053Smarkm * 2 along with this work; if not, write to the Free Software Foundation, 1762053Smarkm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1862053Smarkm * 1962053Smarkm * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2062053Smarkm * CA 95054 USA or visit www.sun.com if you need additional information or 2162053Smarkm * have any questions. 2262053Smarkm */ 2362053Smarkm 2462053Smarkm/* 2562053Smarkm * 2662053Smarkm */ 2762053Smarkm 28119418Sobrienpackage bench.rmi; 29119418Sobrien 30119418Sobrienimport bench.Benchmark; 31256381Smarkmimport java.rmi.Remote; 32256381Smarkmimport java.rmi.RemoteException; 3362053Smarkmimport java.rmi.server.UnicastRemoteObject; 3465686Smarkm 3574914Sjhb/** 36122871Smarkm * Benchmark for testing speed of calls with double array arguments and 3767365Sjhb * return values. 3862053Smarkm */ 3974072Smarkmpublic class DoubleArrayCalls implements Benchmark { 40122871Smarkm 4169168Smarkm interface Server extends Remote { 42143418Sume public double[] call(double[] a) throws RemoteException; 43100082Smarkm } 4469168Smarkm 4567112Smarkm static class ServerImpl extends UnicastRemoteObject implements Server { 46254147Sobrien public ServerImpl() throws RemoteException { 47128059Smarkm } 4867112Smarkm 4962053Smarkm public double[] call(double[] a) throws RemoteException { 50255362Smarkm return a; 51255362Smarkm } 52255362Smarkm } 53255362Smarkm 54255362Smarkm static class ServerFactory implements BenchServer.RemoteObjectFactory { 55255362Smarkm public Remote create() throws RemoteException { 56255362Smarkm return new ServerImpl(); 57255362Smarkm } 58255362Smarkm } 59255362Smarkm 60255362Smarkm /** 61255362Smarkm * Issue double array calls. 62255362Smarkm * Arguments: <array size> <# calls> 63255362Smarkm */ 64255362Smarkm public long run(String[] args) throws Exception { 65255362Smarkm int size = Integer.parseInt(args[0]); 66255362Smarkm int reps = Integer.parseInt(args[1]); 67255362Smarkm BenchServer bsrv = Main.getBenchServer(); 68255362Smarkm Server stub = (Server) bsrv.create(new ServerFactory()); 69255362Smarkm double[] array = new double[size]; 70255362Smarkm 71255362Smarkm long start = System.currentTimeMillis(); 72255362Smarkm for (int i = 0; i < reps; i++) 73255362Smarkm stub.call(array); 74255362Smarkm long time = System.currentTimeMillis() - start; 75255362Smarkm 76255362Smarkm bsrv.unexport(stub, true); 77255362Smarkm return time; 78255362Smarkm } 7974072Smarkm} 8074072Smarkm