From: Pavel V. <va...@us...> - 2002-07-22 00:21:02
|
Update of /cvsroot/javaprofiler/test/module In directory usw-pr-cvs1:/tmp/cvs-serv25961 Added Files: TestAllocHistView.java Log Message: test of histogram view --- NEW FILE: TestAllocHistView.java --- /* * 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.util.*; import javax.swing.*; import javax.swing.table.*; import javax.swing.JFrame; import javax.swing.JScrollPane; import java.awt.*; import net.sourceforge.javaprofiler.module.views.*; import net.sourceforge.javaprofiler.jpi.*; import net.sourceforge.javaprofiler.jpi.connect.*; import net.sourceforge.javaprofiler.jpiimpl.connect.*; /** * * @author Pavel Vacha */ public class TestAllocHistView { VirtualMachineImageRef image; JFrame frame; //RefreshThread refreshTread; /** Creates a new instance of TestAllocHistView */ public TestAllocHistView() { try { VirtualMachineRef vm = connect(); //FIXME WARNING depends on iplementation image = (VirtualMachineImageRef) vm; ((net.sourceforge.javaprofiler.jpiimpl.realtime.ImageR) ((net.sourceforge.javaprofiler.jpiimpl.VirtualMachineImpl) vm). getRealtimeImage() ).refreshTypes(); //image = getSnapshot(vm); frame=new JFrame("Main"); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); JTable table = new AllocHistogramTable( new AllocHistogramTableModel( image.getTypes() ) ); table.setPreferredScrollableViewportSize(new Dimension(600, 600)); JScrollPane scrollPane = new JScrollPane( table ); frame.setSize( 800, 600 ); frame.getContentPane().add( scrollPane, BorderLayout.CENTER); } catch( ConnectingException e) { //System.err.println( "Error in connecting to profiled machine: "); //System.err.println( e.getMessage() ); //e.printStackTrace(); throw new RuntimeException( "Error in connecting to profiled machine: " + e.getMessage() ); } } private 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!" ); */ return vm.createSnapshot(); } private VirtualMachineRef connect() throws ConnectingException { //try { Bootstrap.virtualMachineManager().defaultConnector(); Connector con = new SocketAttachConnector(); Map args = con.defaultArguments(); ((Connector.IntegerArgument) args.get("port")).setValue(25595); ((Connector.Argument) args.get("host")).setValue("localhost"); return (new SocketAttachConnector()).connect( args ); /*} }*/ } public void show() { //frame.pack(); frame.show(); //frame.setVisible(true); } public static void main( String[] arg) { // let's run the test TestAllocHistView test = new TestAllocHistView(); test.show(); } } //TODO //refreshing thread |