@Override public void run() { StopWatch sw = new StopWatch(); sw.start(); double count = 0; try { count++; if (count%1000==0) { System.out.printf("Processed %d images took %s minutes, ~%.2f ms per image.\n", (int) count, StatsUtils.convertTime(sw.getTimeSinceStart()), (double) sw.getTimeSinceStart()/count); sw.stop(); System.out.printf("\nIt's finished. Processing %d images took %s minutes, ~%.2f ms per image.\n", (int) count, StatsUtils.convertTime(sw.getTime()), (double) sw.getTime()/count); } catch (FileNotFoundException e) { e.printStackTrace();
@Override public void run() { StopWatch sw = new StopWatch(); sw.start(); double count = 0; try { count++; if (count%1000==0) { System.out.printf("Processed %d images took %s minutes, ~%.2f ms per image.\n", (int) count, StatsUtils.convertTime(sw.getTimeSinceStart()), (double) sw.getTimeSinceStart()/count); sw.stop(); System.out.printf("\nIt's finished. Processing %d images took %s minutes, ~%.2f ms per image.\n", (int) count, StatsUtils.convertTime(sw.getTime()), (double) sw.getTime()/count); } catch (FileNotFoundException e) { e.printStackTrace();
MetricSpacesImageSearcher mis = new MetricSpacesImageSearcher(100, new FileInputStream(mfile), 500); mis.setNumHashesUsedForQuery(15); StopWatch sw0 = new StopWatch(); sw0.start(); GenericFastImageSearcher gis = new GenericFastImageSearcher(100, CEDD.class, true, reader); sw0.stop(); System.out.printf("Startup latency of cached searcher: %02.3f sec\n", sw0.getTime()/1000d); GenericFastImageSearcher lis = new GenericFastImageSearcher(100, CEDD.class, false, reader); StopWatch sw1 = new StopWatch(); StopWatch sw2 = new StopWatch(); StopWatch sw3 = new StopWatch(); StopWatch sw4 = new StopWatch(); for (int i = 0; i < numRuns; i++) { sw1.start(); ImageSearchHits hits = gis.search(reader.document(i), reader); sw1.stop(); sw2.start(); ImageSearchHits hits = mis.search(reader.document(i), reader); sw2.stop(); sw3.start(); ImageSearchHits hits = is.search(reader.document(i), reader); sw3.stop(); sw4.start(); sw4.stop();
public void testSearchDocValues() throws IOException { IndexReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(indexNameDV))); GenericDocValuesImageSearcher is = new GenericDocValuesImageSearcher(10, CEDD.class, reader); // run search StopWatch sm = new StopWatch(); BufferedImage qImage = ImageIO.read(new FileInputStream(queryImage)); ImageSearchHits hits = null; for (int i = 0; i<numRuns; i++) { sm.start(); hits = is.search(qImage, reader); sm.stop(); } // print results for (int i = 0; i < hits.length(); i++) { String fileName = reader.document(hits.documentID(i)).getValues(GlobalDocumentBuilder.FIELD_NAME_IDENTIFIER)[0]; System.out.println(hits.score(i) + ": \t" + fileName); } System.out.printf("\nTime for searching: %02.3f ms\n", sm.getTime() / (double) numRuns); }
public void testSearchCaching() throws IOException { IndexReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(indexName))); GenericFastImageSearcher is = new GenericFastImageSearcher(10, CEDD.class, true, reader); // run search StopWatch sm = new StopWatch(); BufferedImage qImage = ImageIO.read(new FileInputStream(queryImage)); ImageSearchHits hits = null; for (int i = 0; i<numRuns; i++) { sm.start(); hits = is.search(qImage, reader); sm.stop(); } // print results for (int i = 0; i < hits.length(); i++) { String fileName = reader.document(hits.documentID(i)).getValues(GlobalDocumentBuilder.FIELD_NAME_IDENTIFIER)[0]; System.out.println(hits.score(i) + ": \t" + fileName); } System.out.printf("\nTime for searching: %02.3f ms\n", sm.getTime() / (double) numRuns); }
public void testSearchPlain() throws IOException { IndexReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(indexName))); GenericFastImageSearcher is = new GenericFastImageSearcher(10, CEDD.class, false, reader); // run search StopWatch sm = new StopWatch(); BufferedImage qImage = ImageIO.read(new FileInputStream(queryImage)); ImageSearchHits hits = null; for (int i = 0; i< numRuns; i++) { sm.start(); hits = is.search(qImage, reader); sm.stop(); } // print results for (int i = 0; i < hits.length(); i++) { String fileName = reader.document(hits.documentID(i)).getValues(GlobalDocumentBuilder.FIELD_NAME_IDENTIFIER)[0]; System.out.println(hits.score(i) + ": \t" + fileName); } System.out.printf("\nTime for searching: %02.3f ms\n", sm.getTime() / (double) numRuns); } }
mis.setNumHashesUsedForQuery(5); GenericDocValuesImageSearcher fis = new GenericDocValuesImageSearcher(maxResults, CEDD.class, reader); StopWatch sm = new StopWatch(); StopWatch sf = new StopWatch(); int numRuns = 100; for (int i = 0; i < numRuns; i++) { Document document = reader.document(i); sm.start(); ImageSearchHits hitsM = mis.search(document, reader); sm.stop(); sf.start(); ImageSearchHits hitsF = fis.search(document, reader); sf.stop(); HashSet<Integer> setM = new HashSet<>(maxResults); HashSet<Integer> setF = new HashSet<>(maxResults); intersectSum += intersect; System.out.printf("\nTime for MetricSpaces vs. linear: %02.3f vs. %02.3f seconds for %d runs at %02.2f recall\n", sm.getTime() / 1000d, sf.getTime() / 1000d, numRuns, ((double) intersectSum / (double) numRuns) / ((double) maxResults));