java:index
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java:index [2014/04/13 10:14] – rlunaro | java:index [2024/10/05 17:13] (current) – rlunaro | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Apuntes de Java ====== | ====== Apuntes de Java ====== | ||
- | Varias notas sobre java. | + | Varias notas sobre java. |
Line 13: | Line 13: | ||
* [[eclipse|Eclipse]] | * [[eclipse|Eclipse]] | ||
- | * [[NotasSobrePluginsEclipse|Mis notas sobre plugins eclipse]] | ||
* [[maven|Maven]] | * [[maven|Maven]] | ||
* [[jsf|JSF]] | * [[jsf|JSF]] | ||
Line 28: | Line 27: | ||
* [[http:// | * [[http:// | ||
* [[webxml|Web.xml]] | * [[webxml|Web.xml]] | ||
- | * [[webdav|Java webdav]] | ||
* [[javadoc|Javadoc made easy]] | * [[javadoc|Javadoc made easy]] | ||
* [[javaBeans|Java Beans]] | * [[javaBeans|Java Beans]] | ||
* [[MimeTypes|MimeTypes]] | * [[MimeTypes|MimeTypes]] | ||
+ | </ | ||
**Recipes** | **Recipes** | ||
* [[howToMakeALinkLookLikeAButton|How to make a link look like a button]] | * [[howToMakeALinkLookLikeAButton|How to make a link look like a button]] | ||
+ | * [[http:// | ||
* [[DevelopmentMode|Configurar modo desarrollo]] | * [[DevelopmentMode|Configurar modo desarrollo]] | ||
* [[NumerosAleatorios|Números Aleatorios]] | * [[NumerosAleatorios|Números Aleatorios]] | ||
Line 43: | Line 42: | ||
* [[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 50: | Line 50: | ||
* [[TestPi4J|TestPI4J: | * [[TestPi4J|TestPI4J: | ||
- | * [[MiningTheSocialWeb|Mining the Social Web]] | ||
* [[2by2RubikCube|The Rubik' | * [[2by2RubikCube|The Rubik' | ||
Line 63: | Line 62: | ||
* [[http:// | * [[http:// | ||
* [[Minecraft|Minecraft]] | * [[Minecraft|Minecraft]] | ||
- | </ | + | * [[Sonar|Sonar]] |
Line 105: | Line 105: | ||
</ | </ | ||
- | |||
- | ==== ¿Qué tarda más??? ==== | ||
- | |||
- | Con frecuencia veo construcciones como ésta: | ||
- | |||
- | <code java> | ||
- | if(logger.isInfoEnabled()){ | ||
- | logger.info(" | ||
- | } | ||
- | </ | ||
- | |||
- | En el código Java de otros. "Es para que vaya más rápido" | ||
- | |||
- | |||
- | Me he llevado la sorpresa de que es más rápido sin el '' | ||
- | |||
- | 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 = " | ||
- | // deletes the log file prior to do the test | ||
- | File deleter = new File(" | ||
- | deleter.delete(); | ||
- | |||
- | // start the logger tester | ||
- | Logger logger = Logger.getLogger(" | ||
- | PropertyConfigurator.configure(log4jFile); | ||
- | |||
- | Date start1 = new Date(); | ||
- | for( long count1 = 0; count1 < 1000000; count1++ ) | ||
- | { | ||
- | if(logger.isInfoEnabled()){ | ||
- | logger.info(" | ||
- | } | ||
- | } | ||
- | Date end1 = new Date(); | ||
- | |||
- | Date start2 = new Date(); | ||
- | for( long count2 = 0; count2 < 1000000; count2++ ) | ||
- | { | ||
- | logger.info(" | ||
- | } | ||
- | Date end2 = new Date(); | ||
- | |||
- | |||
- | System.out.println( "con comprobacion tardó: " + (end1.getTime() - start1.getTime())/ | ||
- | System.out.println( "SIN comprobacion tardó: " + (end2.getTime() - start2.getTime())/ | ||
- | } | ||
- | |||
- | |||
- | } | ||
- | |||
- | </ | ||
Line 270: | Line 197: | ||
~~DISQUS~~ | ~~DISQUS~~ | ||
- | |||
- |
java/index.1397384094.txt.gz · Last modified: 2022/12/02 21:02 (external edit)