ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/unittest/TesterThreadedPerformance.java

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

      
    
Rootfs path

      
    
Size
2679 (2.6 KB)
MD5
a356692d55320a4e2f241631e0143ff6
SHA1
39f05894c6359bd1bdabb9edcd3ddb8239f0492c
SHA256
77115155151a4b9722773e4bf3fd15c9b0ffc30b3f3c6909115415030589d49d
SHA512

      
    
SHA1_git
64fc39789d9ec69447eb1003967c33143d4d9e7f
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TesterThreadedPerformance.java | 2.6 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.unittest; import java.util.function.IntConsumer; import java.util.function.Supplier; /* * Support class for threaded performance tests. */ public class TesterThreadedPerformance { private final int threadCount; private final int iterationCount; private final Supplier<IntConsumer> testInstanceSupplier; public TesterThreadedPerformance(int threadCount, int iterationCount, Supplier<IntConsumer> testInstanceSupplier) { this.threadCount = threadCount; this.iterationCount = iterationCount; this.testInstanceSupplier = testInstanceSupplier; } public long doTest() throws InterruptedException { long start = System.nanoTime(); Thread[] threads = new Thread[threadCount]; for (int i = 0; i < threadCount; i++) { IntConsumer testTarget = testInstanceSupplier.get(); threads[i] = new Thread( new TesterThreadedPerformanceRunnable(testTarget, iterationCount)); } for (int i = 0; i < threadCount; i++) { threads[i].start(); } for (int i = 0; i < threadCount; i++) { threads[i].join(); } return System.nanoTime() - start; } private static class TesterThreadedPerformanceRunnable implements Runnable { private final IntConsumer testTarget; private final int iterationCount; TesterThreadedPerformanceRunnable(IntConsumer testTarget, int iterationCount) { this.testTarget = testTarget; this.iterationCount = iterationCount; } @Override public void run() { for (int i = 0; i < iterationCount; i++) { testTarget.accept(i); } } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
44.57
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