User Tools

Site Tools


java:index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
java:index [2014/04/13 12:15] rlunarojava:index [2022/12/02 22:02] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Apuntes de Java ====== ====== Apuntes de Java ======
  
-Varias notas sobre java.+Varias notas sobre java. 
  
  
Line 28: Line 28:
   * [[http://wiki.metawerx.net/wiki/Web.xml]] - toda la documentación sobre "web.xml"   * [[http://wiki.metawerx.net/wiki/Web.xml]] - toda la documentación sobre "web.xml"
   * [[webxml|Web.xml]]   * [[webxml|Web.xml]]
-  * [[webdav|Java webdav]] 
   * [[javadoc|Javadoc made easy]]   * [[javadoc|Javadoc made easy]]
   * [[javaBeans|Java Beans]]   * [[javaBeans|Java Beans]]
Line 37: Line 36:
  
   * [[howToMakeALinkLookLikeAButton|How to make a link look like a button]]   * [[howToMakeALinkLookLikeAButton|How to make a link look like a button]]
 +  * [[http://java67.blogspot.com.es/2015/07/how-to-stop-thread-in-java-example.html|How to stop a thread]]
   * [[DevelopmentMode|Configurar modo desarrollo]]   * [[DevelopmentMode|Configurar modo desarrollo]]
   * [[NumerosAleatorios|Números Aleatorios]]   * [[NumerosAleatorios|Números Aleatorios]]
Line 43: Line 43:
   * [[durationToText|Convert a time duration into a text]]   * [[durationToText|Convert a time duration into a text]]
   * [[javaService|Create your own java windows services using the Jboss service wrapper]]   * [[javaService|Create your own java windows services using the Jboss service wrapper]]
 +  * [[javaServiceLinux|A simple script for creating a service in linux]]
   * [[searchInsideAJarFile|How to search inside a Jar file]]   * [[searchInsideAJarFile|How to search inside a Jar file]]
   * [[allAvailableTimeZones|List all available timezones that are in your JVM]]   * [[allAvailableTimeZones|List all available timezones that are in your JVM]]
Line 63: Line 64:
   * [[http://www2.sys-con.com/ITSG/virtualcd/Java/archives/0612/mair/index.html|Xproperties]]   * [[http://www2.sys-con.com/ITSG/virtualcd/Java/archives/0612/mair/index.html|Xproperties]]
   * [[Minecraft|Minecraft]]   * [[Minecraft|Minecraft]]
 +  * [[Sonar|Sonar]]
  
  
Line 105: Line 107:
 </code> </code>
  
- 
-==== ¿Qué tarda más??? ==== 
- 
-Con frecuencia veo construcciones como ésta:  
- 
-<code java> 
-if(logger.isInfoEnabled()){ 
- logger.info("Prueba de log"); 
-}  
-</code> 
- 
-En el código Java de otros. "Es para que vaya más rápido" me dicen. Muy bien. Vamos a comprobarlo: he hecho un programa de prueba (ver abajo) a ver qué construcción tarda más: si con el isInfo or isDebug o lo que sea, o sin él.  
- 
- 
-Me he llevado la sorpresa de que es más rápido sin el ''if''... justo lo que yo pensaba.  
- 
-Otra mas: para el ejemplo del programa (1.000.000 de ejecuciones) la diferencia es de un segundo. Es decir, la comprobación tarda un microsegundo en hacerse. 
- 
-**No merecería la pena, aunque el resultado fuera al revés:** la legibilidad del código es mejor cuanto más simple.  
- 
-<code java> 
-import java.io.File; 
-import java.util.Date; 
- 
-import org.apache.log4j.Logger; 
-import org.apache.log4j.PropertyConfigurator; 
- 
- 
- 
-public class App { 
-  
- 
- public static final int ERROR_CODE = -1; 
- public static final int OPERATION_OK = 0; 
- 
- /** 
- * @param args 
- */ 
- public static void main(String[] args) { 
- String log4jFile = "c:/workspace/LogTester/src/log4j.properties"; 
- // deletes the log file prior to do the test 
- File deleter = new File("c:/temp/logtester.log"); 
- deleter.delete(); 
- 
- // start the logger tester 
- Logger logger = Logger.getLogger("tester"); 
- PropertyConfigurator.configure(log4jFile); 
-  
- Date start1 = new Date(); 
- for( long count1 = 0; count1 < 1000000; count1++ ) 
- { 
- if(logger.isInfoEnabled()){ 
- logger.info("Prueba de log"); 
- }  
- } 
- Date end1 = new Date();  
-  
- Date start2 = new Date(); 
- for( long count2 = 0; count2 < 1000000; count2++ ) 
- { 
- logger.info("Prueba de log"); 
- } 
- Date end2 = new Date();  
-  
-  
- System.out.println( "con comprobacion tardó: " + (end1.getTime() - start1.getTime())/1000 + " segundos " ); 
- System.out.println( "SIN comprobacion tardó: " + (end2.getTime() - start2.getTime())/1000 + " segundos " ); 
- } 
- 
- 
-} 
- 
-</code> 
  
  
Line 270: Line 199:
  
 ~~DISQUS~~ ~~DISQUS~~
- 
java/index.1397384132.txt.gz · Last modified: 2022/12/02 22:02 (external edit)