|
What this is
Other links
The source code// $Header: /home/cvs/jakarta-jmeter/src/monitor/components/org/apache/jmeter/monitor/util/MemoryBenchmark.java,v 1.2 2004/03/19 23:29:25 sebb Exp $ /* * Copyright 2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jmeter.monitor.util; import java.util.List; import java.util.LinkedList; import org.apache.jmeter.monitor.model.*; import org.apache.jmeter.visualizers.*; /** * * @version $Revision: 1.2 $ $Date: 2004/03/19 23:29:25 $ */ public class MemoryBenchmark { public static void main(String[] args) { if (args.length != 1){ int objects = 10000; if (args[0] != null){ objects = Integer.parseInt(args[0]); } List objs = new LinkedList(); ObjectFactory of = ObjectFactory.getInstance(); long bfree = Runtime.getRuntime().freeMemory(); long btotal = Runtime.getRuntime().totalMemory(); //long bmax = Runtime.getRuntime().maxMemory();//JDK1.4 only System.out.println("Before we create objects:"); System.out.println("------------------------------"); System.out.println("free: " + bfree); System.out.println("total: " + btotal); //System.out.println("max: " + bmax); for (int idx=0; idx < objects; idx++){ Connector cnn = of.createConnector(); Workers wkrs = of.createWorkers(); for (int idz=0; idz < 26; idz++){ Worker wk0 = of.createWorker(); wk0.setCurrentQueryString("/manager/status"); wk0.setCurrentUri("http://localhost/manager/status"); wk0.setMethod("GET"); wk0.setProtocol("http"); wk0.setRemoteAddr("?"); wk0.setRequestBytesReceived(132); wk0.setRequestBytesSent(18532); wk0.setStage("K"); wk0.setVirtualHost("?"); wkrs.getWorker().add(wk0); } cnn.setWorkers(wkrs); RequestInfo rqinfo = of.createRequestInfo(); rqinfo.setBytesReceived(0); rqinfo.setBytesSent(434374); rqinfo.setErrorCount(10); rqinfo.setMaxTime(850); rqinfo.setProcessingTime(2634); rqinfo.setRequestCount(1002); cnn.setRequestInfo(rqinfo); ThreadInfo thinfo = of.createThreadInfo(); thinfo.setCurrentThreadCount(50); thinfo.setCurrentThreadsBusy(12); thinfo.setMaxSpareThreads(50); thinfo.setMaxThreads(150); thinfo.setMinSpareThreads(10); cnn.setThreadInfo(thinfo); Jvm vm = of.createJvm(); Memory mem = of.createMemory(); mem.setFree(77280); mem.setTotal(134210000); mem.setMax(134217728); vm.setMemory(mem); Status st = of.createStatus(); st.setJvm(vm); st.getConnector().add(cnn); MonitorStats mstats = new MonitorStats( Stats.calculateStatus(st), Stats.calculateLoad(st), 0, Stats.calculateMemoryLoad(st), Stats.calculateThreadLoad(st), "localhost", "8080", "http", System.currentTimeMillis()); MonitorModel monmodel = new MonitorModel(mstats); objs.add(monmodel); } long afree = Runtime.getRuntime().freeMemory(); long atotal = Runtime.getRuntime().totalMemory(); //long amax = Runtime.getRuntime().maxMemory();//JDK1.4 only long delta = ((atotal - afree) - (btotal - bfree)); System.out.println("After we create objects:"); System.out.println("------------------------------"); System.out.println("free: " + afree); System.out.println("total: " + atotal); //System.out.println("max: " + amax); System.out.println("------------------------------"); System.out.println("delta: "+ (delta/1024) + " kilobytes"); System.out.println("delta: "+ (delta/1024/1024) + " megabytes"); System.out.println("number of objects: " + objects); System.out.println("potential number of servers: " + (objects/1000)); } else { System.out.println("Please provide the number of objects"); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.