TWaver Web Performance Report


Published on

TWaver is a GUI toolkit which provides Network component and other commonly used components including tree, table, chart, property sheet, list, etc.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

TWaver Web Performance Report

  1. 1. TWaver® Web Performance ReportNov 2010Serva Softwareinfo@servasoftware.comhttp://www.servasoftware.comPO Box 8143, Wichita Falls, Texas, USA 76307
  2. 2. For more information about Serva Software and TWaver please visit the web site at: http://www.servasoftware.comOr send e-mail to: info@servasoftware.comNov, 2010Notice:This document contains proprietary information of Serva Software. Possession and use ofthis document shall be strictly in accordance with a license agreement between the userand Serva Software, and receipt or possession of this document does not convey any rightsto reproduce or disclose its contents, or to manufacture, use, or sell anything it maydescribe. It may not be reproduced, disclosed, or used by others without specific writtenauthorization of Serva Software.TWaver, servasoft, Serva Software and the logo are registered trademarks of ServaSoftware. Java and all Java-based marks are trademarks or registered trademarks of SunMicrosystems, Inc. in the U.S.A. and other countries. Other company, brand, or productnames are trademarks or registered trademarks of their respective holders. Theinformation contained in this document is subject to change without notice at thediscretion of Serva Software.Copyright © 2010 Serva Software LLCAll Rights Reserved
  3. 3.                                                                         TWaver Web P Performance Re eport  Test t Environment  TWaver v3.6  Java(TM M) SE Runtime e Environme ent (build 1.6 6.0_22‐b04‐3 307‐10M326 61)  Mac OSXX 10.6.4  2.26 GHz Intel Core 2 Duo SVG G Export Timee Test  SV VG Byte Size T Test  Node: 200 – 3200  Node: 200 – 3200 Link: 40 – 640  Link: 40 – 640  Unit: mss  Unit: k kb    Source Code for r More Testin ng    1 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  4. 4.                                                                         TWaver Web Performance Report  P e Source Code:  kage test; pack import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component t; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;  yteArrayOutimport tputStream;import OException; import java.util.A ArrayList; import java.util.List;  putStream;import import javax.swing.JButton;  ox; import javax.swing.JCheckBoimport javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField;   Element; import twaver.Eimport twaver.L Link;  2 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  5. 5.                                                                         TWaver Web P Performance Re eport  import twaver.N Node; import twaver.R ResizableNod de; import twaver.T TDataBox;  TUIManager; import twaver.Timport twaver.T TWaverConst t; import twaver.T TWaverUtil; import twaver.chart.BarChart;  web.svg.netwimport twaver.w work.SVGCon ntext; import twaver.w web.svg.netw work.TSVGNe etwork;  public class SVGPerformance eTest extend ds JPanel imp plements Act tionListener {  vate int stepC priv Count = 5;  priv vate int unitN Number = 20 00;    vate JPanel c priv controlPane = = new JPanel();  priv vate JCheckB Box withImag ge = new JCh heckBox("wit th image"); priv vate JCheckB Box base64 = = new JCheck kBox("use ba ase64");  priv vate JTextFie eld stepCountField = new stepCount + "");  w JTextField(s priv vate JTextFie eld unitNumb berField = ne ew JTextField d(unitNumbe er + "");  priv vate JButton testButton = = new JButto on("do test") );    priv vate Node bo oxLoad = new w Node();  priv vate Node sv vgExport = ne ew Node(); priv vate Node sv vgSize = new Node();  priv vate Node co ompressedSize = new No ode();  3 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  6. 6.                                                                         TWaver Web P Performance Re eport    ataBox box = TDa = new TDataB Box();  TSV VGNetwork n network = ne ew TSVGNetw work(box);   BarChart chart = = new BarCh hart();   BarChart svgSizeChart = new w BarChart(){  otected Strin  pro ng getFormat tedText(Elem ment elemen nt, double value, int index x) {    ret turn super.getFormatedT Text(elemen nt, value, index) + "kb";   }  };    blic SVGPerfo pub ormanceTest t() {   sup per(new Bord derLayout()) );   JPa anel mainPan anel(new GridLayout(1, 1 ne = new JPa 1));   this s.add(mainP Pane, BorderLayout.CENT TER);   ma ainPane.add( (chart);   ma ainPane.add( (svgSizeChart);     s.add(contro  this olPane, BorderLayout.SO OUTH);    con dd(withImage e);   con dd(base64);   epCountField  ste d.setPreferre edSize(new D Dimension(30 0, 20));  4 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  7. 7.                                                                         TWaver Web Performance Report  P e   uni itNumberFie eld.setPreferredSize(new w Dimension( (80, 20));   con dd(new JLabe el("step coun nt"));   con dd(stepCount tField);   con dd(new JLabe el("node cou unt"));   con dd(unitNumb berField);  con dd(testButton);   stButton.add  tes dActionListen ner(this);     tCharts();   init }   vate void init priv tCharts() {   cha art.getDataB Box().addElem ment( oxLoad);   cha art.getDataB Box().addElem ment(this.svg gExport);   svg etDataBox().addElement t(this.svgSize e);   svg etDataBox().addElement t(this.compre essedSize);     xLoad.setName("DataBo  box ox Loading Time");   svg gExport.setName("SVG Exporting Tim me");   svg gSize.setNam me("Uncompressed SVG B Byte Size");  com mpressedSize.setName(" "Compressed d SVG Byte S Size");     xLoad.putCh  box hartColor(Col lor.BLUE.dar rker());  5 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  8. 8.                                                                         TWaver Web P Performance Re eport    svg gExport.putC ChartColor(Co olor.GREEN.darker());   svg gSize.putChartColor(Colo or.GREEN.brighter());   com mpressedSize.putChartColor(Color.G GREEN.darker r());   art.setYAxisT  cha Text("Time Consuming (m ms)");   cha art.setTitle("TWaver SVG G Performanc ce Report ‐ T Time");   cha art.setValueT TextFont( etDefaultFon nt().deriveFont(9f));   cha art.setShado owOffset(0);   cha art.setSelectedOffset(0);   cha art.setBarTyp pe(TWaverConst.BAR_TY YPE_GROUP) ); //  c chart.setXSca aleTextOrientation(TWav verConst.LAB BEL_ORIENTA ATION_RIGH HT);   cha art.setXScale eTextColor(Color.RED);   cha art.setLazyPu ublishMode( (true);   cha art.setXAxisT Text("Numbe ers of Element");  svg "SVG File Size (kb)");  etYAxisText("  svg etTitle("TWaver SVG Perf formance Re eport ‐ Byte S Size");   svg etValueTextF Font(TUIMan nager.getDef faultFont().deriveFont(9f f));   svg etShadowOff fset(0);   svg etSelectedOf ffset(0);   svg etBarType(TW WaverConst. .BAR_TYPE_G GROUP); //  svgSizeChart. .setXScaleTextOrientatio on(TWaverCo ORIENTATION_RIGHT);  onst.LABEL_O  svg etXScaleText tColor(Color.RED);   svg etLazyPublish hMode(true) );  6 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  9. 9.                                                                         TWaver Web P Performance Report  e   svg etXAxisText(" "Numbers of f Element");    }    blic static void main(Strin pub ng[] args) {   sho owFrame("", , new SVGPerformanceTe est());  }   blic static JFrame showFr pub rame(String t title, Component component) {   JFrame frame = = new JFrame();   frame.setTitle(t title);   frame.getConte dd(component, BorderLa entPane().ad ayout.CENTER);   frame.setSize(8 800, 500);   frame.setDefau ultCloseOper ration(JFram me.EXIT_ON_ _CLOSE);  WaverUtil.cen  TW nterWindow(frame);   frame.setVisible(true);  turn frame;   ret }   Override  @O pub blic void actio onPerformed d(ActionEven nt e) {   tes stButton.setE Enabled(false e);   ste epCountField d.setEnabled(false);   uni itNumberFie eld.setEnable ed(false);     7 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  10. 10.                                                                         TWaver Web P Performance Re eport    this s.stepCount = arseInt(this.s stepCountFie eld.getText()) );   this s.unitNumbe er = Integer.p parseInt(this s.unitNumbe erField.getTe ext());     s.chart.setXS  this ScaleTextList t(null);   this s.svgSizeCha art.setXScaleTextList(null);   this etChartValue es(null);   this s.svgExport.s setChartValu ues(null);   this s.svgSize.set tChartValues s(null);   this s.compresse edSize.setCha artValues(nu ull);      int step = 0;     hile(step < ste  wh epCount){      t nodeCount   int t = (int)(unitN Number*(Ma ath.pow(2, st tep)));    int t linkCount = = (int)(nodeC Count*0.2);   bo oolean useIco on = false;    bo oolean useBa ase64 = base64.isSelected();      ng boxLoadT   lon Time = loadN Node(box, no nkCount, useIcon, 1000, 8 odeCount, lin 800);    lon ng[] svgInfo = = exportSVG G(useBase64) );    lon ng exportSVG GTime = svgI Info[0];    lon ng svgByteSize = svgInfo[ [1];    lon ng svgByteCo ize = svgInfo[2];  ompressedSi     8 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  11. 11.                                                                         TWaver Web P Performance Re eport     this.chart.addX XScaleText("<html>"+nod deCount + " Nodes <br>" "+linkCount++" Links</htmml>");    this.svgSizeCha art.addXScaleText("<htm ml>"+nodeCo ount + " Node es <br>"+link kCount+" Linkks</html>");        this.boxLoad.a addChartValu ue(boxLoadT Time);    this.svgExport. .addChartValue(exportSV VGTime); ddChartValue e(svgByteSize e/1024);    this.compresse edSize.addCh hartValue(sv vgByteCompr ressedSize/1 1024);  ep++;    ste  }   stButton.setE  tes Enabled(true e);   ste epCountField d.setEnabled(true);   uni itNumberFie eld.setEnable ed(true);  }      vate long[] ex priv xportSVG(bo oolean useBa ase64){   lon ng time = Sys stem.current tTimeMillis(); ;   SVG GContext context = new SVGContext t();   con ntext.setUseBase64(useB Base64);   String svg = net twork.toSVG G(context);   int size = svg.length();  me = System.currentTime  tim eMillis() ‐ tim me;     ng svgCompressedSize = 0  lon 0;  9 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  12. 12.                                                                         TWaver Web P Performance Re eport    try {  yteArrayOutp   By putStream ou ut = new Byt teArrayOutputStream();   GZ ZIPOutputStr ream out2 = new GZIPOu utputStream(out);    ou ut2.write(svg g.getBytes()); ;    ou ut2.flush();    ou ut2.close();    svg gCompressedSize = out.s size();    System.out.pri intln(svgCom mpressedSize e);  ut.close();    ou  } ca atch (IOException e) {    e.p printStackTra ace();   }     turn new long[]{time, size  ret e, svgCompr ressedSize}; }    blic static lon pub (TDataBox box, int nodeC ng loadNode( Count, int lin olean useIcon, int  nkCount, booxLim mit, int yLimitt){   box x.clear();         long start = System.curr rentTimeMill lis();  es = new Arra        List allNode ayList(nodeC Count);         for (int i = 0 0; i < nodeCount; i++) {          ResizableNode node  = new Resizab bleNode();  ze(12, 12);          node.setSiz         node.putBo orderColor(C Color.YELLOW W);          node.putLa abelColor(new Color(160 0, 160, 160));  10 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  13. 13.                                                                         TWaver Web P Performance Re eport           node.setNa ame(""+i);             if (!useIco on) {           node.putCustomDraw( (true);           node.putCustomDrawS ShapeFactor ry (TWaverCo onst.SHAPE_ _ROUND);           node.putCustomDrawFFillColor(neww Color(80 + TWaverUtil.getRandomI Int(120), 80 + + TWa averUtil.getR RandomInt(1 120), 100));           node.putCustomDrawO OutlineColor r(Color.WHIT TE);             }   WaverUtil.get            int x = TW tRandomInt( (xLimit);             int y = TW WaverUtil.get tRandomInt( (yLimit);              node.setL Location(x, y y);             box.addElement(node e);             allNodes.add(node);         }  0; i < linkCoun        for (int i = 0 nt; i++) {             Node nod de1 = (Node) )allNodes.get t (TWaverUt til.getRandom mInt(nodeCo ount));             Node nod de2 = (Node) )allNodes.get t (TWaverUt til.getRandom mInt(nodeCo ount));               = createLink(            Link link = (node1, node e2, null);             link.setNa ame(""+i);             link.putLa abelColor(Co olor.GRAY);             box.addElement(link);         }  em.currentTi        return Syste imeMillis()‐start;  11 Copy All Rights Reser   yright © 2010 Serva Software A rved 
  14. 14.                                                                         TWaver Web P Performance Report  e     }    vate static Lin priv nk createLink(Node from m, Node to, S String name){ {   Link link = new Link(from, to);  k.setName(n  link name);   link k.putLinkOut tlineWidth(1 1);   link k.putLinkOut tlineColor(Co olor.BLACK);  link k.putLinkWid dth(1);   link k.putLinkColor(Color.WH HITE);   ret turn link;  } }  12 Copy All Rights Reser   yright © 2010 Serva Software A rved