2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org/forester
26 package org.forester.development;
29 import java.io.IOException;
30 import java.util.Date;
32 import org.forester.io.parsers.nhx.NHXParser;
33 import org.forester.phylogeny.Phylogeny;
34 import org.forester.phylogeny.PhylogenyNode;
35 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
36 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
37 import org.forester.util.BasicDescriptiveStatistics;
38 import org.forester.util.DescriptiveStatistics;
40 @SuppressWarnings( "unused")
41 public final class Time {
43 public static void main( final String[] args ) {
45 final DescriptiveStatistics parse_stats = new BasicDescriptiveStatistics();
46 final DescriptiveStatistics post_stats = new BasicDescriptiveStatistics();
47 final DescriptiveStatistics pre_stats = new BasicDescriptiveStatistics();
48 final File f = new File( args[ 0 ] );
50 for( int i = 0; i < 10; i++ ) {
51 final long start_time = new Date().getTime();
52 phy = ParserBasedPhylogenyFactory.getInstance().create( f, new NHXParser() )[ 0 ];
53 System.out.println( phy.getNumberOfExternalNodes() );
54 parse_stats.addValue( new Date().getTime() - start_time );
56 PhylogenyNode n = null;
57 final long start_time_post = new Date().getTime();
58 final PhylogenyNodeIterator post = phy.iteratorPostorder();
59 while ( post.hasNext() ) {
62 post_stats.addValue( new Date().getTime() - start_time_post );
64 final long start_time_pre = new Date().getTime();
65 final PhylogenyNodeIterator pre = phy.iteratorPreorder();
66 while ( pre.hasNext() ) {
69 pre_stats.addValue( new Date().getTime() - start_time_pre );
71 System.out.println( "Parsing [ms]:" );
72 System.out.println( parse_stats.toString() );
73 System.out.println( "Post-order [ms]:" );
74 System.out.println( post_stats.toString() );
75 System.out.println( "Pre-order [ms]:" );
76 System.out.println( pre_stats.toString() );
78 catch ( final IOException e ) {