|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.openide; import java.io.*; import java.util.*; import org.netbeans.performance.Benchmark; public class ErrorManagerTest extends Benchmark { static { Properties prop = System.getProperties(); prop.put("perf.test.enabled", "-5"); // prop.put("perf.test.disabled", "0x1000000"); } private static final ErrorManager enabled; private static final ErrorManager disabled; static { ErrorManager en = ErrorManager.getDefault().getInstance("perf.test.enabled"); enabled = en.isLoggable(ErrorManager.INFORMATIONAL) ? en : null; ErrorManager dis = ErrorManager.getDefault().getInstance("perf.test.disabled"); disabled = dis.isLoggable(ErrorManager.INFORMATIONAL) ? dis : null; assertNull("disabled is loggable", disabled); } public ErrorManagerTest(String name) { super( name ); } public void testLogEnabled() throws Exception { int count = getIterationCount(); ErrorManager en = ErrorManager.getDefault().getInstance("perf.test.enabled"); while( count-- > 0 ) { // do the stuff here, en.log("Logging event #" + count); } } public void testLogDisabled() throws Exception { int count = getIterationCount(); ErrorManager dis = ErrorManager.getDefault().getInstance("perf.test.disabled"); while( count-- > 0 ) { // do the stuff here, dis.log("Logging event #" + count); } } public void testCheckedEnabled() throws Exception { int count = getIterationCount(); ErrorManager en = ErrorManager.getDefault().getInstance("perf.test.enabled"); while( count-- > 0 ) { // do the stuff here, if(en.isLoggable(ErrorManager.INFORMATIONAL)) en.log("Logging event #" + count); } } public void testCheckedDisabled() throws Exception { int count = getIterationCount(); ErrorManager dis = ErrorManager.getDefault().getInstance("perf.test.disabled"); while( count-- > 0 ) { // do the stuff here, if(dis.isLoggable(ErrorManager.INFORMATIONAL)) dis.log("Logging event #" + count); } } public void testNullEnabled() throws Exception { int count = getIterationCount(); while( count-- > 0 ) { // do the stuff here, if(enabled != null) enabled.log("Logging event #" + count); } } public void testNullDisabled() throws Exception { int count = getIterationCount(); while( count-- > 0 ) { // do the stuff here, if(disabled != null) disabled.log("Logging event #" + count); } } public void testNull16Disabled() throws Exception { int count = getIterationCount(); while( count-- > 0 ) { // do the stuff here, if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); if(disabled != null) disabled.log("Logging event #" + count); } } public static void main(String[] args) { simpleRun( ErrorManager.class ); } /** Crippled version of NbErrorManager that does the logging the same way */ public static final class EM extends ErrorManager { /** The writer to the log file*/ private PrintWriter logWriter = new PrintWriter(System.err); /** Minimum value of severity to write message to the log file*/ private int minLogSeverity = ErrorManager.INFORMATIONAL + 1; // NOI18N /** Prefix preprended to customized loggers, if any. */ private String prefix = null; // Make sure two distinct EM impls log differently even with the same name. private int uniquifier = 0; // 0 for root EM (prefix == null), else >= 1 static final Map uniquifiedIds = new HashMap(20); // Map |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.