/[projects]/dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Lookup.java
ViewVC logotype

Diff of /dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Lookup.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2214 by torben, Fri Sep 12 06:42:29 2014 UTC revision 2227 by torben, Mon Sep 22 07:39:46 2014 UTC
# Line 37  public class Lookup { Line 37  public class Lookup {
37                    
38          static Statistik flestDaekkede = new Statistik();          static Statistik flestDaekkede = new Statistik();
39          static Statistik flestIkkeDaekkede = new Statistik();          static Statistik flestIkkeDaekkede = new Statistik();
40            static Statistik mestBrugteTid = new Statistik();
41            static Statistik stoersteDataset = new Statistik();
42                    
43                    
44          static class Statistik {          static class Statistik {
45                  int postnr;                  int postnr;
46                  int antalDaekkede = 0;                  int antalDaekkede = 0;
47                  int antalIkkeDaekkede = 0;                  int antalIkkeDaekkede = 0;
48                    int totalDataset = 0;          
49                    long forbrugtTid = 0;
50    
51                                    
52                  @Override                  @Override
53                  public String toString() {                  public String toString() {
54                          return "postnr=" + postnr + " antalIkkeDaekkede=" + antalIkkeDaekkede + " antalDaekkede="  + antalDaekkede;                          return "postnr=" + postnr + " antalIkkeDaekkede=" + antalIkkeDaekkede + " antalDaekkede="  + antalDaekkede + " forbrugtTid=" + forbrugtTid + " totalDataset=" + totalDataset;
55                  }                  }
56          }          }
57                    
# Line 62  public class Lookup { Line 67  public class Lookup {
67                  }                  }
68                  if (stat.antalIkkeDaekkede > flestIkkeDaekkede.antalIkkeDaekkede) {                  if (stat.antalIkkeDaekkede > flestIkkeDaekkede.antalIkkeDaekkede) {
69                          flestIkkeDaekkede = stat;                          flestIkkeDaekkede = stat;
70                  }                                }
71                    
72                    if (stat.totalDataset > mestBrugteTid.totalDataset) {
73                            stoersteDataset = stat;
74                    }
75                    
76                    if (stat.forbrugtTid > mestBrugteTid.forbrugtTid) {
77                            mestBrugteTid = stat;
78                    }
79          }          }
80                    
81          public void doLookup() throws BoundingBoxException {          public void doLookup() throws BoundingBoxException {
# Line 90  public class Lookup { Line 103  public class Lookup {
103                          stat.postnr = postnr;                          stat.postnr = postnr;
104                          stat.antalDaekkede = daekkedeAdresser.length;                          stat.antalDaekkede = daekkedeAdresser.length;
105                          stat.antalIkkeDaekkede = queue.size();                          stat.antalIkkeDaekkede = queue.size();
106                                                    stat.totalDataset = stat.antalDaekkede * stat.antalIkkeDaekkede;
107                          saveStatistics(stat);                                                                          
                                                   
108                                                    
109                          logger.info("Starter beregning for " + postnr);                          logger.info("Starter beregning for " + postnr);
110                          start2 = System.currentTimeMillis();                          start2 = System.currentTimeMillis();
# Line 109  public class Lookup { Line 121  public class Lookup {
121                                  Thread.sleep(10);//wait for worker threads                                  Thread.sleep(10);//wait for worker threads
122                          }                          }
123                                                    
124                            db.saveBatch();//Save any unsaved rows
125                            
126                                                    
127                  } catch(Exception e) {                  } catch(Exception e) {
128                          logger.log(Level.WARNING, "Exception during lookup", e);                          logger.log(Level.WARNING, "Exception during lookup", e);
# Line 121  public class Lookup { Line 135  public class Lookup {
135                  }                  }
136                  long now = System.currentTimeMillis();                  long now = System.currentTimeMillis();
137                                    
138                    stat.forbrugtTid = (now-start1);
139                    saveStatistics(stat);
140    
141                  logger.info( stat.toString() );                  logger.info( stat.toString() );
142                  logger.info("Done! elapsed=" + (now-start1) + "/" +  (now-start2) + "  postnr=" + postnr);                  logger.info("Done! elapsed=" + (now-start1) + "/" +  (now-start2) + "  postnr=" + postnr);
# Line 175  public class Lookup { Line 191  public class Lookup {
191                                    
192                                    
193                                    
                   
194                  File confFile = new File( CONFIG_FILENAME );                  File confFile = new File( CONFIG_FILENAME );
195                  if (! confFile.exists() ) {                  if (! confFile.exists() ) {
196                          logger.warning("Config file not found: " + CONFIG_FILENAME);                          logger.warning("Config file not found: " + CONFIG_FILENAME);
# Line 235  public class Lookup { Line 250  public class Lookup {
250                  }                  }
251                                    
252                  long now = System.currentTimeMillis();                  long now = System.currentTimeMillis();
253                    long elapsed = now - start ;
254    
255                    logger.info("Mest brugte tid: " + mestBrugteTid);
256                  logger.info("Flest Ikke-dækkede, " + flestIkkeDaekkede);                  logger.info("Flest Ikke-dækkede, " + flestIkkeDaekkede);
257                  logger.info("Flest Dækkede, " + flestDaekkede);                  logger.info("Flest Dækkede, " + flestDaekkede);
258                  logger.info("Fuld load done : " + (now-start) );                  logger.info("Største Dataset, " + stoersteDataset);
259                    logger.info("Fuld load done : " + formatMilliSeconds(elapsed) );
260    
261                                    
262                  /*                  /*
# Line 247  public class Lookup { Line 265  public class Lookup {
265                  Lookup lookup = new Lookup(2750, db);                  Lookup lookup = new Lookup(2750, db);
266                  lookup.doLookup();                                lookup.doLookup();              
267                  long now = System.currentTimeMillis();                  long now = System.currentTimeMillis();
268                  logger.info("Fuld load done : " + (now-start) );*/                  long elapsed = now - start ;
269                    logger.info("Fuld load done : " + formatMilliSeconds(elapsed) );*/
270            }
271            
272            static String formatMilliSeconds(long milliseconds) {
273                    int mseconds = (int) milliseconds % 1000;
274                    int seconds = (int) (milliseconds / 1000) % 60 ;
275                    int minutes = (int) ((milliseconds / (1000*60)) % 60);
276                    int hours   = (int) ((milliseconds / (1000*60*60)) % 24);
277                    
278                    return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, mseconds);
279          }          }
280                                    
281  }  }

Legend:
Removed from v.2214  
changed lines
  Added in v.2227

  ViewVC Help
Powered by ViewVC 1.1.20