You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2017/03/29 09:16:16 UTC
[1/2] brooklyn-server git commit: Adds perf test for xml serialiser
(and memento-gem)
Repository: brooklyn-server
Updated Branches:
refs/heads/master a940d4996 -> 5e0749ef9
Adds perf test for xml serialiser (and memento-gem)
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/f0fa7b90
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/f0fa7b90
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/f0fa7b90
Branch: refs/heads/master
Commit: f0fa7b90faa7b2578cbf463021fa666eadfc9a35
Parents: a940d49
Author: Aled Sage <al...@gmail.com>
Authored: Fri Mar 17 22:22:32 2017 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Mar 28 13:21:02 2017 +0100
----------------------------------------------------------------------
.../XmlMementoSerializerPerformanceTest.java | 111 +++++++++++++++++++
.../dto/MementoGeneratorsPerformanceTest.java | 89 +++++++++++++++
2 files changed, 200 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f0fa7b90/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializerPerformanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializerPerformanceTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializerPerformanceTest.java
new file mode 100644
index 0000000..8ebeeb5
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializerPerformanceTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.brooklyn.core.mgmt.persist;
+
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.mgmt.rebind.mementos.Memento;
+import org.apache.brooklyn.api.policy.PolicySpec;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.api.sensor.EnricherSpec;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.mgmt.rebind.dto.MementosGenerators;
+import org.apache.brooklyn.core.objs.BasicSpecParameter;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.core.test.policy.TestEnricher;
+import org.apache.brooklyn.core.test.policy.TestPolicy;
+import org.apache.brooklyn.core.test.qa.performance.AbstractPerformanceTest;
+import org.apache.brooklyn.test.performance.PerformanceTestDescriptor;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class XmlMementoSerializerPerformanceTest extends AbstractPerformanceTest {
+
+ private XmlMementoSerializer<Object> serializer;
+
+ @BeforeMethod(alwaysRun=true)
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ serializer = new XmlMementoSerializer<Object>(XmlMementoSerializerPerformanceTest.class.getClassLoader());
+ }
+
+ protected int numIterations() {
+ return 1000;
+ }
+
+ @Test(groups={"Live", "Acceptance"})
+ public void testSerializeEntityMemento() throws Exception {
+ int numIterations = numIterations();
+ double minRatePerSec = 10 * PERFORMANCE_EXPECTATION;
+
+ // Create an entity with lots of config/parameters, and sensors
+ Map<ConfigKey<?>, String> config = Maps.newLinkedHashMap();
+ List<BasicSpecParameter<?>> params = Lists.newArrayList();
+ for (int i = 0; i < 100; i++) {
+ ConfigKey<String> key = ConfigKeys.newStringConfigKey("myparam"+i);
+ params.add(new BasicSpecParameter<String>("mylabel"+i, false, key));
+ config.put(key, "val"+i);
+ }
+ Entity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .configure(TestEntity.CONF_NAME, "myname")
+ .configure(config)
+ .parametersAdd(params)
+ .tags(ImmutableList.<Object>of("tag1", "tag2"))
+ .enricher(EnricherSpec.create(TestEnricher.class))
+ .policy(PolicySpec.create(TestPolicy.class)));
+
+ for (int i = 0; i < 100; i++) {
+ AttributeSensor<String> sensor = Sensors.newStringSensor("mysensor"+i);
+ entity.sensors().set(sensor, "valsensor"+i);
+ }
+
+ // Create the memento for that entity (only once)
+ final Memento memento = MementosGenerators.newBasicMemento(Entities.deproxy(entity));
+ int serializedLength = serializeToString(memento).length();
+
+ // Run the performance test
+ measure(PerformanceTestDescriptor.create()
+ .summary("mementoSerializer.serializeEntityMemento(size="+serializedLength+"chars)")
+ .iterations(numIterations)
+ .minAcceptablePerSecond(minRatePerSec)
+ .job(new Runnable() {
+ @Override public void run() {
+ serializeToString(memento);
+ }}));
+ }
+
+ private String serializeToString(Object val) {
+ StringWriter writer = new StringWriter();
+ serializer.serialize(val, writer);
+ return writer.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f0fa7b90/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementoGeneratorsPerformanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementoGeneratorsPerformanceTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementoGeneratorsPerformanceTest.java
new file mode 100644
index 0000000..7051808
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/dto/MementoGeneratorsPerformanceTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.brooklyn.core.mgmt.rebind.dto;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.policy.PolicySpec;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.api.sensor.EnricherSpec;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.objs.BasicSpecParameter;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.core.test.policy.TestEnricher;
+import org.apache.brooklyn.core.test.policy.TestPolicy;
+import org.apache.brooklyn.core.test.qa.performance.AbstractPerformanceTest;
+import org.apache.brooklyn.test.performance.PerformanceTestDescriptor;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class MementoGeneratorsPerformanceTest extends AbstractPerformanceTest {
+
+ protected int numIterations() {
+ return 100;
+ }
+
+ @Test(groups={"Live", "Acceptance"})
+ public void testGenerateEntityMemento() throws Exception {
+ int numIterations = numIterations();
+ double minRatePerSec = 10 * PERFORMANCE_EXPECTATION;
+
+ // Create an entity with lots of config/parameters, and sensors
+ Map<ConfigKey<?>, String> config = Maps.newLinkedHashMap();
+ List<BasicSpecParameter<?>> params = Lists.newArrayList();
+ for (int i = 0; i < 100; i++) {
+ ConfigKey<String> key = ConfigKeys.newStringConfigKey("myparam"+i);
+ params.add(new BasicSpecParameter<String>("mylabel"+i, false, key));
+ config.put(key, "val"+i);
+ }
+ Entity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .configure(TestEntity.CONF_NAME, "myname")
+ .configure(config)
+ .parametersAdd(params)
+ .tags(ImmutableList.<Object>of("tag1", "tag2"))
+ .enricher(EnricherSpec.create(TestEnricher.class))
+ .policy(PolicySpec.create(TestPolicy.class)));
+
+ for (int i = 0; i < 100; i++) {
+ AttributeSensor<String> sensor = Sensors.newStringSensor("mysensor"+i);
+ entity.sensors().set(sensor, "valsensor"+i);
+ }
+
+ final Entity deproxiedEntity = Entities.deproxy(entity);
+
+ // Run the performance test
+ measure(PerformanceTestDescriptor.create()
+ .summary("mementosGenerators.newBasicMemento(entity)")
+ .iterations(numIterations)
+ .minAcceptablePerSecond(minRatePerSec)
+ .job(new Runnable() {
+ @Override public void run() {
+ MementosGenerators.newBasicMemento(deproxiedEntity);
+ }}));
+ }
+}
[2/2] brooklyn-server git commit: This closes #600
Posted by al...@apache.org.
This closes #600
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/5e0749ef
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/5e0749ef
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/5e0749ef
Branch: refs/heads/master
Commit: 5e0749ef93d84f22ab730fc6345cece7023be162
Parents: a940d49 f0fa7b9
Author: Aled Sage <al...@gmail.com>
Authored: Wed Mar 29 10:16:05 2017 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Mar 29 10:16:05 2017 +0100
----------------------------------------------------------------------
.../XmlMementoSerializerPerformanceTest.java | 111 +++++++++++++++++++
.../dto/MementoGeneratorsPerformanceTest.java | 89 +++++++++++++++
2 files changed, 200 insertions(+)
----------------------------------------------------------------------