cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r638963 - in /incubator/cxf/trunk: benchmark/profiling/ benchmark/profiling/src/main/java/org/apache/cxf/profile/ common/common/src/main/java/org/apache/cxf/configuration/spring/
Date Wed, 19 Mar 2008 18:28:41 GMT
Author: bimargulies
Date: Wed Mar 19 11:28:38 2008
New Revision: 638963

URL: http://svn.apache.org/viewvc?rev=638963&view=rev
Log:
A small but measurable speedup in spring initialization.

Added:
    incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java
  (with props)
Modified:
    incubator/cxf/trunk/benchmark/profiling/build.xml
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java

Modified: incubator/cxf/trunk/benchmark/profiling/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/benchmark/profiling/build.xml?rev=638963&r1=638962&r2=638963&view=diff
==============================================================================
--- incubator/cxf/trunk/benchmark/profiling/build.xml (original)
+++ incubator/cxf/trunk/benchmark/profiling/build.xml Wed Mar 19 11:28:38 2008
@@ -1,4 +1,4 @@
-<project name="CXF JProfile" default="run">
+<project name="CXF JProfile" default="compile">
 
    <property name="jprofile.home" location="/opt/jprofiler5"/>
    <property name="cxf.dist" location="../../distribution/target/apache-cxf-2.1-incubator-SNAPSHOT.dir/apache-cxf-2.1-incubator-SNAPSHOT"/>
@@ -152,11 +152,24 @@
     </delete>
   </target>
 
-  <target name="run" depends="compile,setNativeLibDir" description="Run the offline profiling
sample">
+  <target name="run-client-endpoint" depends="compile,setNativeLibDir" description="Run
the offline profiling sample">
 
     <java classname="org.apache.cxf.profile.ClientEndpointCreationLoop" fork="true">
       <arg value="100"/>
       <arg value="client_endpoint.jps"/>
+      <jvmarg value="-agentlib:jprofilerti=offline,id=146,config=jprofileConfig.xml"></jvmarg>
+      <jvmarg value="-Xbootclasspath/a:${jprofile.home}/bin/agent.jar"></jvmarg>
+      <env key="LD_LIBRARY_PATH" path="${nativelib.dir}:${nativelib.envvarValue}"/>
+
+      <classpath refid="run-classpath"/>
+    </java>
+  </target>
+
+  <target name="run-bus-init" depends="compile,setNativeLibDir" description="Run the offline
profiling sample">
+
+    <java classname="org.apache.cxf.profile.DefaultBusInitialization" fork="true">
+      <arg value="100"/>
+      <arg value="bus_initialization.jps"/>
       <jvmarg value="-agentlib:jprofilerti=offline,id=146,config=jprofileConfig.xml"></jvmarg>
       <jvmarg value="-Xbootclasspath/a:${jprofile.home}/bin/agent.jar"></jvmarg>
       <env key="LD_LIBRARY_PATH" path="${nativelib.dir}:${nativelib.envvarValue}"/>

Added: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java?rev=638963&view=auto
==============================================================================
--- incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java
(added)
+++ incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java
Wed Mar 19 11:28:38 2008
@@ -0,0 +1,53 @@
+/**
+ * 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.cxf.profile;
+
+import com.jprofiler.api.agent.Controller;
+
+import java.io.File;
+
+import org.apache.cxf.BusFactory;
+
+/**
+ * 
+ */
+public class DefaultBusInitialization {
+    
+    public static void main(String[] args) {
+        Controller.stopAllocRecording();
+        Controller.stopCPURecording();
+        DefaultBusInitialization dbi = new DefaultBusInitialization();
+        Controller.startCPURecording(true);
+        Controller.startAllocRecording(true);
+        int count = Integer.parseInt(args[0]);
+        for (int x = 0; x < count; x++) {
+            dbi.iteration();
+        }
+        Controller.stopAllocRecording();
+        Controller.stopCPURecording();
+        if (args.length > 1) {
+            Controller.saveSnapshot(new File(args[1]));
+        }
+    }
+
+    private void iteration() {
+        BusFactory.newInstance().createBus();
+    }
+}

Propchange: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/benchmark/profiling/src/main/java/org/apache/cxf/profile/DefaultBusInitialization.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=638963&r1=638962&r2=638963&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Wed Mar 19 11:28:38 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.configuration.spring;
 
+import java.util.Map;
 import java.util.StringTokenizer;
 
 import javax.xml.bind.JAXBContext;
@@ -32,6 +33,7 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.cxf.common.util.CacheMap;
 import org.apache.cxf.helpers.DOMUtils;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -44,9 +46,9 @@
 
 public abstract class AbstractBeanDefinitionParser 
     extends org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser {
-
+    private static Map<String, JAXBContext> packageContextCache = new CacheMap<String,
JAXBContext>(); 
     private Class beanClass;
-
+    
     @Override
     protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean)
{
         boolean setBus = parseAttributes(element, ctx, bean);        
@@ -255,7 +257,11 @@
             if (null != c && c.getPackage() != null) {
                 pkg = c.getPackage().getName();
             }
-            context = JAXBContext.newInstance(pkg, getClass().getClassLoader());
+            context = packageContextCache.get(pkg);
+            if (context == null) {
+                context = JAXBContext.newInstance(pkg, getClass().getClassLoader());
+                packageContextCache.put(pkg, context);
+            }
             Unmarshaller u = context.createUnmarshaller();
             if (c != null) {
                 obj = u.unmarshal(data, c);



Mime
View raw message