ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/bcel/TesterPerformance.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/bcel/TesterPerformance.java
Status
scanned
Type
file
Name
TesterPerformance.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3073 (3.0 KB)
MD5
d92075fe042ecf979ca1c2dcd8bddd6a
SHA1
d5c7cd8b2aaab1b8e3ba3d68b0ef88042c1b708a
SHA256
f327654c1caef4ca01a39aa3f40bf43eea5c0f70972a18258c038458d90a8f29
SHA512

      
    
SHA1_git
63be1ab8d774d36a273a7285287fb8f8ff27d886
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TesterPerformance.java | 3.0 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.bcel; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URL; import java.util.HashSet; import java.util.Locale; import java.util.Set; import org.junit.Assert; import org.junit.Test; import org.apache.tomcat.Jar; import org.apache.tomcat.util.bcel.classfile.ClassParser; import org.apache.tomcat.util.scan.JarFactory; /* * This is an absolute performance test. There is no benefit it running it as part of a standard test run so it is * excluded due to the name starting Tester... * * The test also requires that the Jira lib directory has been extracted from a Jira install and copied to /tmp. */ public class TesterPerformance { private static final String JAR_LOCATION = "/tmp/jira-libs"; @Test public void testClassParserPerformance() throws IOException { File libDir = new File(JAR_LOCATION); String[] libs = libDir.list(); Assert.assertNotNull(libs); Set<URL> jarURLs = new HashSet<>(); for (String lib : libs) { if (!lib.toLowerCase(Locale.ENGLISH).endsWith(".jar")) { continue; } jarURLs.add(URI.create("jar:" + new File (libDir, lib).toURI().toURL().toExternalForm() + "!/").toURL()); } long duration = 0; for (URL jarURL : jarURLs) { try (Jar jar = JarFactory.newInstance(jarURL)) { jar.nextEntry(); String jarEntryName = jar.getEntryName(); while (jarEntryName != null) { if (jarEntryName.endsWith(".class")) { InputStream is = jar.getEntryInputStream(); long start = System.nanoTime(); ClassParser cp = new ClassParser(is); cp.parse(); duration += System.nanoTime() - start; } jar.nextEntry(); jarEntryName = jar.getEntryName(); } } } System.out.println("ClassParser performance test took: " + duration + " ns"); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
33.9
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9