You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@nutch.apache.org by Lourival Júnior <ju...@gmail.com> on 2006/07/27 14:17:34 UTC

Total time of a search

Hi,

Somebody knows how to calculate the total time of a search? Actually a use
this, but I'm not sure about it:

Date d = new Date();
int iniTime = (int) d.getTime();//pega o tempo de inicio da execução da
busca nos índices

//Aqui é executada a busca nos índices.
try{
    hits = bean.search(query, start + hitsToRetrieve, hitsPerSite, "site",
sort, reverse);
} catch (IOException e){
    hits = new Hits(0,new Hit[0]);
}


int end = (int)Math.min(hits.getLength(), start + hitsPerPage);
int length = end-start;
int realEnd = (int)Math.min(hits.getLength(), start + hitsToRetrieve);


Hit[] show = hits.getHits(start, realEnd-start);
HitDetails[] details = bean.getDetails(show);
String[] summaries = bean.getSummary(details, query);

Date d2 = new Date();
int endTime = (int) d2.getTime();
int totalTime = endTime-iniTime;//tempo de execução em milisegundos
double totalTimeInSec = (double)totalTime/(double)1000;

Is it correct?

-- 
Lourival Junior
Universidade Federal do Pará
Curso de Bacharelado em Sistemas de Informação
http://www.ufpa.br/cbsi
Msn: junior_ufpa@hotmail.com

RE: Total time of a search

Posted by "NG-Marketing, M.Schneider" <sc...@ng-marketing.com>.
Hy,

I use the following code to measure it in millisecs:

  // Stoppuhr
  class Stoppuhr {
	long millis;
	void starte()
		{ millis = System.currentTimeMillis(); }
	
	void stoppe()
		{ millis = System.currentTimeMillis() - millis; }
	
	long lies()

	{ return millis; }
  }


  // START STOPUHR
  Stoppuhr t = new Stoppuhr();
  t.starte();

..... SEARCH

<% t.stoppe(); out.println(t.lies()/1000.000 + " sec"); %>


Mit freundlichen Grüßen
Matthias Schneider
 

Sedanstrasse 27
D-97082 Wuerzburg (Germany)
 
web://    www.ng-marketing.com
mail://    schneider@ng-marketing.com
tel://      0700 ngmarketing
tel2://    +49 . 931 . 207 410 7
fax://     +49 . 931 . 207 410 8
 

> -----Original Message-----
> From: Lourival Júnior [mailto:junior.ufpa@gmail.com]
> Sent: Thursday, July 27, 2006 2:18 PM
> To: nutch-user@lucene.apache.org
> Subject: Total time of a search
> 
> Hi,
> 
> Somebody knows how to calculate the total time of a search? Actually a use
> this, but I'm not sure about it:
> 
> Date d = new Date();
> int iniTime = (int) d.getTime();//pega o tempo de inicio da execução da
> busca nos índices
> 
> //Aqui é executada a busca nos índices.
> try{
>     hits = bean.search(query, start + hitsToRetrieve, hitsPerSite, "site",
> sort, reverse);
> } catch (IOException e){
>     hits = new Hits(0,new Hit[0]);
> }
> 
> 
> int end = (int)Math.min(hits.getLength(), start + hitsPerPage);
> int length = end-start;
> int realEnd = (int)Math.min(hits.getLength(), start + hitsToRetrieve);
> 
> 
> Hit[] show = hits.getHits(start, realEnd-start);
> HitDetails[] details = bean.getDetails(show);
> String[] summaries = bean.getSummary(details, query);
> 
> Date d2 = new Date();
> int endTime = (int) d2.getTime();
> int totalTime = endTime-iniTime;//tempo de execução em milisegundos
> double totalTimeInSec = (double)totalTime/(double)1000;
> 
> Is it correct?
> 
> --
> Lourival Junior
> Universidade Federal do Pará
> Curso de Bacharelado em Sistemas de Informação
> http://www.ufpa.br/cbsi
> Msn: junior_ufpa@hotmail.com