This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Websphere and the fly likes for jdk1.2.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark " for jdk1.2.2" Watch " for jdk1.2.2" New topic
Author for jdk1.2.2

Raj Varanasi

Joined: Nov 20, 2001
Posts: 11
Hi ,
Anybody got the source code for compatible with jdk1.2.2,I have an older version which works fine with jdk1.1.8.When i am trying to use this with WebsphereV3.5.4(jdk1.2.2) for analyzing verbosegc output in stderr.
Here is the source code i got

// This utility tabulates data generated from a verbose garbage collection trace.
// To run this utility type:
// java GCStats inputfile [total_time]
// Gennaro (Jerry) Cuomo - IBM Corp. 03/2000
// Carmine F. Greco 3/17/00 - JDK1.2.2 compatibility
import java.util.*;
public class GCStats {
static int total_time=-1; // total time of run in ms
static long total_gctime=0, total_gctime1=0; // total time spent in GCs
static long total_bytes=0, total_bytes1=0; // total bytes collected
static long total_free=0, total_free1=0; // total
static int total_gc=0; // total number of GCs
static boolean verbose=false; // debug trace on/off
public static void parseLine(String line) {
// parsing a string that looks like this...
// <GC(31): freed 16407744 bytes in 107 ms, 97% free (16417112/16777208)>
if (isGCStatsLine(line)) { // First test if line starts with "<GC..."<br /> if (verbose) System.out.println("GOT a GC - "+line);<br /> long temp=numberBefore(line, " bytes")/1024; // get total memory collected<br /> total_bytes+=temp; total_bytes1+=(temp*temp);<br /> temp=numberBefore(line, " ms"); // get time in GC<br /> total_gctime+=temp; total_gctime1+=(temp*temp);<br /> temp=numberBefore(line, "% free"); // get time % free<br /> total_free+=temp; total_free1+=(temp*temp);<br /> if (temp!=0) {<br /> total_gc++; // total number of GCs<br /> }<br /> }<br /> }<br /> public static int numberBefore( String line, String s) {<br /> int ret = 0;<br /> int idx = line.indexOf(s);<br /> int idx1= idx-1;<br /> if (idx>0) {
// the string was found, now walk backwards until we find the blank
while (idx1!=0 && line.charAt(idx1)!=' ') idx1--;
if (idx1>0) {
String temp=line.substring(idx1+1,idx);
if (temp!=null) {
ret=Integer.parseInt(temp); // convert from string to number
} else {
if (verbose) System.out.println("ERROR: numberBefore() - Parse Error looking for "+s);
return ret;
public static boolean isGCStatsLine(String line) {
return ( (line.indexOf("<GC") > -1) && (line.indexOf(" freed")>0) && (line.indexOf(" bytes")>0));
public static void main (String args[]) {
String filename=null;
BufferedReader foS=null;
boolean keepgoing=true;
if (args.length==0) {
System.out.println("GCStats - ");
System.out.println(" - ");
System.out.println(" - Syntax: GCStats filename [run_duration(ms)]");
System.out.println(" - filename = file containing -verbosegc data");
System.out.println(" - run_duration(ms) = duration of fixed work run in which GCs took place");
if (args.length>0) {
if (args.length>1) {
if (verbose) System.out.println("Filename="+filename);
try {
foS = new BufferedReader(new FileReader(filename));
} catch (Throwable e) {
System.out.println("Error opening file="+filename);
while (keepgoing) {
String nextLine;
try {
} catch (Throwable e) {
System.out.println("Cannot read file="+filename);
if (nextLine!=null) {
} else {
try {
} catch (Throwable e) {
System.out.println("Cannot close file="+filename);
System.out.println("- GC Statistics for file - "+filename);
System.out.println("-**** Totals ***");
System.out.println("- "+total_gc+" Total number of GCs");
System.out.println("- "+total_gctime+" ms. Total time in GCs");
System.out.println("- "+total_bytes+" Kbytes. Total memory collected during GCs");
System.out.println("- ");
System.out.println("-**** Averages ***");
double mean=total_gctime/total_gc,
int imean=new Double(mean).intValue(), istddev=new Double(stddev).intValue();
System.out.println("- "+imean+" ms. Average time per GC. (stddev="+istddev+" ms.)");
mean=total_bytes/total_gc; stddev=Math.sqrt((total_bytes1-2*mean*total_bytes+total_gc*mean*mean)/total_gc);
imean=new Double(mean).intValue(); istddev=new Double(stddev).intValue();
System.out.println("- "+imean+" Kbytes. Average memory collected per GC. (stddev="+istddev+" Kbytes)");
mean=total_free/total_gc; stddev=Math.sqrt((total_free1-2*mean*total_free+total_gc*mean*mean)/total_gc);
imean=new Double(mean).intValue(); istddev=new Double(stddev).intValue();
System.out.println("- "+imean+"%. Free memory after each GC. (stddev="+istddev+"%)");
if (total_time>0 && total_gctime>0) {
System.out.println("- "+((total_gctime*1.0)/(total_time*1.0))*100.0+"% of total time ("+total_time+"ms.) spentin GC.");
System.out.println("___________________________ "+new Date());
Thanks in Advance
Raj Varanasi
I agree. Here's the link:
subject: for jdk1.2.2
It's not a secret anymore!