1338N/A/*
1338N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
1338N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1338N/A *
1338N/A * This code is free software; you can redistribute it and/or modify it
1338N/A * under the terms of the GNU General Public License version 2 only, as
1338N/A * published by the Free Software Foundation.
1338N/A *
1338N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1338N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1338N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1338N/A * version 2 for more details (a copy is included in the LICENSE file that
1338N/A * accompanied this code).
1338N/A *
1338N/A * You should have received a copy of the GNU General Public License version
1338N/A * 2 along with this work; if not, write to the Free Software Foundation,
1338N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1338N/A *
1338N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1338N/A * or visit www.oracle.com if you need additional information or have any
1338N/A * questions.
1338N/A */
1338N/A
1338N/A/*
1338N/A *
1338N/A */
1338N/A
1338N/Apackage bench.rmi;
1338N/A
1338N/Aimport bench.Benchmark;
1338N/Aimport java.rmi.Remote;
1338N/Aimport java.rmi.RemoteException;
1338N/Aimport java.rmi.server.UnicastRemoteObject;
1338N/A
1338N/A/**
1338N/A * Benchmark for testing speed of calls with boolean arguments/return values.
1338N/A */
1338N/Apublic class BooleanCalls implements Benchmark {
1338N/A
1338N/A interface Server extends Remote {
1338N/A public boolean call(boolean val) throws RemoteException;
1938N/A }
1938N/A
1338N/A static class ServerImpl extends UnicastRemoteObject implements Server {
1338N/A public ServerImpl() throws RemoteException {
1338N/A }
1338N/A
1338N/A public boolean call(boolean val) throws RemoteException {
1338N/A return val;
1338N/A }
1338N/A }
1338N/A
1338N/A static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue boolean calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(true);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}