ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/http/TesterCookiesPerformance.java

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

      
    
Rootfs path

      
    
Size
2967 (2.9 KB)
MD5
336796cad7da1bda01169b74d591d4dd
SHA1
d0cdc7965ce9ee5b43fdcd30e47f389bf6f3c578
SHA256
34864fdadfe222a1b36807ddd9eec0cb5387bb2ef61c1d56fe3860c61b7cfa97
SHA512

      
    
SHA1_git
fcf991c23f4df2a9309a3ae651ff5bc62b6a4887
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TesterCookiesPerformance.java | 2.9 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.http; import org.junit.Assert; import org.junit.Test; import org.apache.tomcat.util.buf.MessageBytes; /* * 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... */ public class TesterCookiesPerformance { @Test public void testPerformance01() throws Exception { final int cookieCount = 100; final int parsingLoops = 200000; MimeHeaders mimeHeaders = new MimeHeaders(); StringBuilder cookieHeader = new StringBuilder(); // Create cookies for (int i = 0; i < cookieCount; i++) { cookieHeader.append("name"); cookieHeader.append(i); cookieHeader.append('='); cookieHeader.append("value"); cookieHeader.append(i); cookieHeader.append(';'); } byte[] cookieHeaderBytes = cookieHeader.toString().getBytes("UTF-8"); MessageBytes headerValue = mimeHeaders.addValue("Cookie"); headerValue.setBytes(cookieHeaderBytes, 0, cookieHeaderBytes.length); ServerCookies serverCookies = new ServerCookies(4); Rfc6265CookieProcessor rfc6265CookieProcessor = new Rfc6265CookieProcessor(); // warm up for (int i = 0; i < parsingLoops; i++) { rfc6265CookieProcessor.parseCookieHeader(mimeHeaders, serverCookies); Assert.assertEquals(cookieCount, serverCookies.getCookieCount()); serverCookies.recycle(); } long newStart = System.nanoTime(); for (int i = 0; i < parsingLoops; i++) { rfc6265CookieProcessor.parseCookieHeader(mimeHeaders, serverCookies); Assert.assertEquals(cookieCount, serverCookies.getCookieCount()); serverCookies.recycle(); } long newDuration = System.nanoTime() - newStart; System.out.println("RFC6265 duration: " + newDuration); // As of November 2021 markt's desktop runs this test in 970ms to 1000ms } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
38.14
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