Author: jboynes
Date: Sat Mar  7 16:29:25 2015
New Revision: 1664887

URL: http://svn.apache.org/r1664887
Log:
Add perf test

Added:
    tomcat/sandbox/niofs/tst/niofs/PerfTest.java   (with props)
    tomcat/sandbox/niofs/urls.log
Modified:
    tomcat/sandbox/niofs/src/niofs/ArchiveFileSystemProvider.java

Modified: tomcat/sandbox/niofs/src/niofs/ArchiveFileSystemProvider.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/niofs/src/niofs/ArchiveFileSystemProvider.java?rev=1664887&r1=1664886&r2=1664887&view=diff
==============================================================================
--- tomcat/sandbox/niofs/src/niofs/ArchiveFileSystemProvider.java (original)
+++ tomcat/sandbox/niofs/src/niofs/ArchiveFileSystemProvider.java Sat Mar  7 
16:29:25 2015
@@ -281,10 +281,9 @@ public class ArchiveFileSystemProvider e
                     continue;
                 }
                 DirectoryNode parentNode = directory.get(parent);
-                if (parentNode == null) {
-                    throw new IllegalStateException("Missing directory entry" 
+ parent);
+                if (parentNode != null) {
+                    parentNode.addChild(path);
                 }
-                parentNode.addChild(path);
             }
             return directory;
         }

Added: tomcat/sandbox/niofs/tst/niofs/PerfTest.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/niofs/tst/niofs/PerfTest.java?rev=1664887&view=auto
==============================================================================
--- tomcat/sandbox/niofs/tst/niofs/PerfTest.java (added)
+++ tomcat/sandbox/niofs/tst/niofs/PerfTest.java Sat Mar  7 16:29:25 2015
@@ -0,0 +1,88 @@
+/*
+ * 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 niofs;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class PerfTest {
+
+    private final ArchiveFileSystemProvider provider = new 
ArchiveFileSystemProvider();
+
+    @Test
+    public void replay() throws Exception {
+        // Read all the paths in we are meant to open;
+        List<String> paths;
+        try (BufferedReader reader = new BufferedReader(new 
FileReader("urls.log"))) {
+            paths = reader.lines().collect(Collectors.toList());
+        }
+
+        long total = -System.nanoTime();
+
+        Path war = 
FileSystems.getDefault().getPath("greenhouse-1.0.0.BUILD-SNAPSHOT.war");
+        FileSystem fileSystem = provider.newFileSystem(war, 
Collections.emptyMap());
+        System.out.println("initial index = " + (total + System.nanoTime()) / 
1000000);
+        Path root = fileSystem.getPath("/");
+
+        long time = -System.nanoTime();
+        Map<String, FileSystem> jars = new HashMap<>();
+        for (String path : paths) {
+            String[] fields = path.split(" ");
+            String jarName = fields[0];
+            String resourceName = fields[1];
+            FileSystem jar = jars.get(jarName);
+            if (jar == null) {
+                Path jarPath = fileSystem.getPath("/", jarName);
+                jar = provider.newFileSystem(jarPath, Collections.emptyMap());
+                jars.put(jarName, jar);
+            }
+            InputStream is = Files.newInputStream(jar.getPath("/", 
resourceName));
+            is.close();
+        }
+        time += System.nanoTime();
+        System.out.println("time including opens = " + time / 1000000);
+
+        time = -System.nanoTime();
+        for (String path : paths) {
+            String[] fields = path.split(" ");
+            String jarName = fields[0];
+            String resourceName = fields[1];
+            FileSystem jar = jars.get(jarName);
+            InputStream is = Files.newInputStream(jar.getPath("/", 
resourceName));
+            is.close();
+        }
+        time += System.nanoTime();
+        System.out.println("time already opened = " + time / 1000000);
+        total += System.nanoTime();
+        System.out.println("total = " + total / 1000000);
+    }
+}

Propchange: tomcat/sandbox/niofs/tst/niofs/PerfTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to