private static void serialize(DataOutputStream out,MethodGroup[] methods) throws IOException {
  out.writeInt(SNAPSHOT_MAGIC);
  out.writeInt(SNAPSHOT_PROTOCOL_VERSION);
  out.writeInt(SNAPSHOT_TYPE_CALLTRACE);
  out.writeInt(sessionId);
  out.writeLong(System.currentTimeMillis());
  int n=0;
  for (  MethodGroup m : methods) {
    if (m.hits > 0) {
      n++;
    }
  }
  Log.print(0,"Retrieving " + n + " methods");
  out.writeInt(n);
  for (  MethodGroup m : methods) {
    if (m.hits == 0) {
      continue;
    }
    out.writeInt(m.globalId & 0xffff);
    out.writeUTF(m.name);
    out.writeInt(m.hits);
    out.writeLong(m.netTime);
    out.writeLong(m.selfTime);
    out.writeInt(m.childCount);
    for (int i=0; i < m.childCount; i++) {
      out.writeInt(m.children[i].globalId & 0xffff);
      out.writeLong(m.childrenTimes[i]);
    }
  }
}

private static void serialize ( DataOutputStream out , MethodGroup [ ] methods ) throws IOException { out . writeInt ( SNAPSHOT_MAGIC ) ; out . writeInt ( SNAPSHOT_PROTOCOL_VERSION ) ; out . writeInt ( SNAPSHOT_TYPE_CALLTRACE ) ; out . writeInt ( sessionId ) ; out . writeLong ( System . currentTimeMillis ( ) ) ; int n = 0 ; for ( MethodGroup m : methods ) { if ( m . hits > 0 ) { n ++ ; } } Log . print ( 0 , "Retrieving " + n + " methods" ) ; out . writeInt ( n ) ; for ( MethodGroup m : methods ) { if ( m . hits == 0 ) { continue ; } out . writeInt ( m . globalId & 0xffff ) ; out . writeUTF ( m . name ) ; out . writeInt ( m . hits ) ; out . writeLong ( m . netTime ) ; out . writeLong ( m . selfTime ) ; out . writeInt ( m . childCount ) ; for ( int i = 0 ; i < m . childCount ; i ++ ) { out . writeInt ( m . children [ i ] . globalId & 0xffff ) ; out . writeLong ( m . childrenTimes [ i ] ) ; } } }
serializes the statistics about a group of methods .
