You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2020/07/23 11:04:40 UTC

[ignite] 01/01: Add enum bench

This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch enum-serialization-perf
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit bc0ef24b473466ef1c21dc48315b8dc5924ddd97
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jul 23 14:04:04 2020 +0300

    Add enum bench
---
 .../Apache.Ignite.BenchmarkDotNet/EnumSerPerf.cs   | 99 ++++++++++++++++++++++
 .../Apache.Ignite.BenchmarkDotNet/Program.cs       |  2 +-
 2 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/EnumSerPerf.cs b/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/EnumSerPerf.cs
new file mode 100644
index 0000000..6735f50
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/EnumSerPerf.cs
@@ -0,0 +1,99 @@
+namespace Apache.Ignite.BenchmarkDotNet
+{
+    using Apache.Ignite.Core;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Client;
+    using global::BenchmarkDotNet.Attributes;
+
+    public class EnumSerPerf
+    {
+        /** */
+        public IIgnite Ignite { get; set; }
+        
+        public ICache<int, object> Cache { get; set; }
+
+        /// <summary>
+        /// Sets up the benchmark.
+        /// </summary>
+        [GlobalSetup]
+        public virtual void GlobalSetup()
+        {
+            Ignite = Ignition.Start(Utils.GetIgniteConfiguration());
+            Cache = Ignite.GetOrCreateCache<int, object>("c");
+        }
+
+        /// <summary>
+        /// Cleans up the benchmark.
+        /// </summary>
+        [GlobalCleanup]
+        public virtual void GlobalCleanup()
+        {
+            Ignite.Dispose();
+        }
+        
+        [Benchmark]
+        public void PutFoo()
+        {
+            Cache.Put(1, new Foo());
+        }
+        
+        [Benchmark]
+        public void PutFooWithEnum()
+        {
+            Cache.Put(1, new FooWithEnum());
+        }
+
+        private class Foo : IBinarizable
+        {
+            public string Bar { get; set; }
+            
+            public void WriteBinary(IBinaryWriter writer)
+            {
+                writer.WriteString("bar", Bar);
+            }
+
+            public void ReadBinary(IBinaryReader reader)
+            {
+                throw new System.NotImplementedException();
+            }
+        }
+        
+        private class FooWithEnum : IBinarizable
+        {
+            public string Bar { get; set; }
+            
+            public MyEnum MyEnum { get; set; }
+            
+            public void WriteBinary(IBinaryWriter writer)
+            {
+                writer.WriteString("bar", Bar);
+                writer.WriteEnum("enum", MyEnum);
+            }
+
+            public void ReadBinary(IBinaryReader reader)
+            {
+                throw new System.NotImplementedException();
+            }
+        }
+
+        private enum MyEnum
+        {
+            Undefined,
+            Stock,
+            Option,
+            Future,
+            Bond,
+            Strategy,
+            DNTP,
+            Forex,
+            ForexFW,
+            Repo,
+            CFD,
+            TAPO,
+            CDS,
+            Swap,
+            Forward
+        }
+    }
+}
\ No newline at end of file
diff --git a/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/Program.cs b/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/Program.cs
index 784b7a6..f2edf0e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/Program.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.BenchmarkDotNet/Program.cs
@@ -30,7 +30,7 @@ namespace Apache.Ignite.BenchmarkDotNet
         /// </summary>
         public static void Main()
         {
-            BenchmarkRunner.Run<ThinClientCacheGetBenchmark>();
+            BenchmarkRunner.Run<EnumSerPerf>();
         }
     }
 }