tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From password password <bernadelpradocla...@yahoo.es>
Subject sort an array
Date Mon, 26 Jun 2006 16:26:22 GMT
Hi, 
   
   I have a servlet and in this servlet I have a problem when sort an array. If in Tomcat
5.5.4 (on windows) the order is very fast (about 2 seconds) , but in tomcat 5.5.9 is slower
(about 25 seconds). I don't Know why the same code has diferent time.
  The code is the next. The array has 7000 elements.
  //////////////////////////////////////////////////////////////////////////////////////////////////////////
  java.util.Date datTiempoInicio, datTiempoFin;
java.util.Calendar calTiempoInicio  = Calendar.getInstance();
java.util.Calendar calTiempoFin     = Calendar.getInstance();
long intTiempoUtilizado;
datTiempoInicio = new java.util.Date();
calTiempoInicio.setTime(datTiempoInicio );

       if (astrName.length > 1) {
       //ordenacion de los arrays: astrName[intFilaArray] 
         int i, pasadas;
         String strTemp;
         double dblIntensityTemp;
         double dblBackgroundTemp;
         int intComparacion;
            for (pasadas = 1; pasadas < astrName.length; pasadas++) {
             for (i = 0; i<astrName.length - 1; i++) {
                 intComparacion = astrName[i].compareTo(astrName[i+1]);
                 if (intComparacion > 0) {
                      strTemp         = astrName[i]; 
                    astrName[i]     = astrName[i + 1]; 
                    astrName[i + 1] = strTemp; 
                      dblIntensityTemp      = adblIntensity1[i]; 
                    adblIntensity1[i]     = adblIntensity1[i + 1]; 
                    adblIntensity1[i + 1] = dblIntensityTemp; 
                      dblIntensityTemp      = adblIntensity2[i]; 
                    adblIntensity2[i]     = adblIntensity2[i + 1]; 
                    adblIntensity2[i + 1] = dblIntensityTemp; 
                      dblBackgroundTemp      = adblBackground1[i]; 
                    adblBackground1[i]     = adblBackground1[i + 1]; 
                    adblBackground1[i + 1] = dblBackgroundTemp; 
                      dblBackgroundTemp      = adblBackground2[i]; 
                    adblBackground2[i]     = adblBackground2[i + 1]; 
                    adblBackground2[i + 1] = dblBackgroundTemp; 
                }  // end if (intComparacion > 0)
         } //end for i 
       } //end for pasadas
      
      } // end if (astrName.length > 1) 
  
datTiempoFin = new java.util.Date();
calTiempoFin.setTime(datTiempoFin );
  
intTiempoUtilizado = Math.abs( (calTiempoFin.getTimeInMillis() - calTiempoInicio.getTimeInMillis())
/ (1000) );
System.out.println("(ProcessFile) Time  = " + intTiempoUtilizado );
   ////////////////////////////////////////////////////////////////////////////////////////////////
   
   
  Can You help me?
   

 		
---------------------------------

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message