|
From: Pavel V. <va...@us...> - 2002-09-07 19:38:49
|
Update of /cvsroot/javaprofiler/test/snapshot In directory usw-pr-cvs1:/tmp/cvs-serv1766 Added Files: TestDiffSnap.java Log Message: test of diff snapshot --- NEW FILE: TestDiffSnap.java --- package snapshot; //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 TestDiffSnap { public Snapshot 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 snap1 = vm.createSnapshot(); long end = System.currentTimeMillis(); System.out.println( "\nTime TestSnap: " + (end - start) ); return snap1; } public Snapshot makeDiffSnapshot( Snapshot snap1, Snapshot snap2 ) { System.out.println("Making diffSnapshot .."); Snapshot result = snap1.differenceTo( snap2 ); System.out.println("OK"); return result; } public void runTest() { Bootstrap.connectorManager().defaultConnector(); try { Connector con = new ShmemAttachConnector(); Map args = con.defaultArguments(); ((Connector.Argument) args.get("address")).setValue("com"); VirtualMachineRef vm= (new ShmemAttachConnector()).connect( args ); System.out.println( "Ready" ); Snapshot snap1, snap2, snapDiff; snap1 = getSnapshot( vm ); while ( !vm.isShutdown() ) { Thread.sleep( 1000); } snap2 = getSnapshot( vm ); vm.shutdown(); vm.dispose(); snapDiff = makeDiffSnapshot( snap1, snap2 ); } 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 TestDiffSnap()).runTest(); } }; //GetCurtime |