From: Pavel V. <va...@us...> - 2002-07-11 18:43:00
|
Update of /cvsroot/javaprofiler/test/snapshot In directory usw-pr-cvs1:/tmp/cvs-serv7539 Added Files: TestSnap2.java runsnap2.bat Log Message: Test of a snapshot. It uses connectors and VirtualMachine to create the snapshot. --- NEW FILE: TestSnap2.java --- //java -Xrun\Project\javaprof\library\src\profiler\profiler:commun_type=socket Notepad /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ import java.lang.*; import java.util.*; import net.sourceforge.javaprofiler.jpi.*; import net.sourceforge.javaprofiler.jpi.connect.*; import net.sourceforge.javaprofiler.jpiimpl.connect.*; /** Creates snapshot using connectors. */ public class TestSnap2 { public void getSnapShot( VirtualMachineRef vm ) { /* SnapshotImpl.Configuration conf = new SnapshotImpl.Configuration(); conf.withCPU = true; conf.withAlloc = true; conf.withMon = true; conf.withArenas = true; conf.withGC = true; conf.withFields = true; conf.withCPUTraces = true; conf.withMonTraces = true; conf.withAllocTraces = true; conf.withCPUThreads = true; conf.withMonThreads = true; conf.withAllocThreads = true; conf.withTypes = true; conf.withCallTree = true; //only traces with more hits than this will be extracted conf.CPUTraces_MinVal = IProf.NO_OPTIONAL_ARG; //2; //only traces with more allocations than this will be extracted conf.AllocTraces_MinVal = IProf.NO_OPTIONAL_ARG; //2; //only traces with more hits than this will be extracted conf.MonTraces_MinVal = IProf.NO_OPTIONAL_ARG; //2; if ( !conf.isValid() ) System.err.print( "Error in snapshot configuration!" ); */ long start = System.currentTimeMillis(); Snapshot mirror = vm.createSnapshot(); System.out.println( mirror.time() ); long end = System.currentTimeMillis(); System.out.println( "\n\nTime TestSnap: " + (end - start) ); } public void runTest() { Bootstrap.virtualMachineManager().defaultConnector(); try { Connector con = new SocketAttachConnector(); Map args = con.defaultArguments(); ((Connector.IntegerArgument) args.get("port")).setValue(25595); ((Connector.Argument) args.get("host")).setValue("localhost"); VirtualMachineRef vm= (new SocketAttachConnector()).connect( args ); System.out.println( "Ready" ); getSnapShot( vm ); } catch( Exception e) { System.err.println( "an error occurred, exception:"); System.err.println( e.getClass().getName()); e.printStackTrace(); } } public static void main( String[] arg) { // let's run the test (new TestSnap2()).runTest(); } }; //GetCurtime --- NEW FILE: runsnap2.bat --- SET JAVA_HOME=d:\programs\j2sdk1.4.0 rem **************************** rem SET CLASSPATH=..\..\jpiimpl;..\..\interface;.\;%CLASSPATH% SET CLASSPATH=..\..\jpiimpl\jpiimpl.jar;.\;%CLASSPATH% set path=%JAVA_HOME%\bin;%path%;..\..\library\src2 java TestSnap2 |