Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implemented the drop database command and started writing the C# vers…

…ion of the 10gen driver benchmark.
  • Loading branch information...
commit 8d8d147fb2b2eac02edbd391353cf1bbfc212b23 1 parent 1fdaeb6
Samuel Corder authored
View
2  .gitignore
@@ -25,3 +25,5 @@ MongoDB.Linq/obj/*
MongoDB.Linq.Tests/bin/*
MongoDB.Linq.Tests/obj/*
MongoDB.Linq.Tests/test-results/*
+
+MongoDB.Driver.Benchmark/bin/*
View
26 MongoDB.Driver.Benchmark/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("MongoDB.Driver.Benchmark")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
View
105 MongoDB.Driver.Benchmark/Main.cs
@@ -0,0 +1,105 @@
+using System;
+
+namespace MongoDB.Driver.Benchmark
+{
+ /// <summary>
+ /// This is the standard 10gen benchmark program.
+ /// </summary>
+ class MainClass
+ {
+ static Document small = new Document();
+ static Document medium = new Document();
+ static Document large = new Document();
+
+ static int trials = 2;
+ static int perTrial = 5000;
+ static int batchSize = 100;
+
+ static void SetupDocuments(){
+ medium.Append("integer", (int) 5);
+ medium.Append("number", 5.05);
+ medium.Append("boolean", false);
+ medium.Append("array", new String[]{"test","benchmark"});
+
+ large.Append("base_url", "http://www.example.com/test-me");
+ large.Append("total_word_count", (int)6743);
+ large.Append("access_time", DateTime.UtcNow);
+ large.Append("meta_tags", new Document()
+ .Append("description", "i am a long description string")
+ .Append("author", "Holly Man")
+ .Append("dynamically_created_meta_tag", "who know\n what"));
+ large.Append("page_structure", new Document().Append("counted_tags", 3450)
+ .Append("no_of_js_attached", (int)10)
+ .Append("no_of_images", (int)6));
+ string[] words = new string[]{"10gen","web","open","source","application","paas",
+ "platform-as-a-service","technology","helps",
+ "developers","focus","building","mongodb","mongo"};
+ string[] harvestedWords = new string[words.Length * 20];
+ for(int i = 0; i < words.Length * 20; i++){
+ harvestedWords[i] = words[i % words.Length];
+ }
+ large.Append("harvested_words", harvestedWords);
+ }
+
+ static void SetupInsert(Database db, string col){
+ try{
+ db.MetaData.DropCollection(col);
+ }catch(MongoCommandException mce){
+ //swallow for now.
+ }
+ }
+
+ static void TestInsert(string name, Database db, string col, Document doc){
+ TimeSpan ret = TimeSpan.MaxValue;
+ for(int i = 0; i < trials; i++){
+ DateTime start = DateTime.Now;
+ Insert(db,col,doc);
+ DateTime stop = DateTime.Now;
+ TimeSpan t = stop - start;
+ if(t < ret){
+ ret = t;
+ }
+ }
+
+ int opsSec = (int)(perTrial/ret.TotalSeconds);
+ Console.Out.WriteLine(String.Format("{0}{1} {2}", name + new string('.', 60 - name.Length), opsSec, ret));
+ }
+
+ static void Insert(Database db, string col, Document doc){
+ for(int i = 0; i < perTrial; i++){
+ Document ins = new Document();
+ doc.CopyTo(ins);
+ ins.Append("x", i);
+ db[col].Insert(ins);
+ }
+ }
+ static void runInsertTest(string name, Database db, string col, Document doc, bool index){
+ SetupInsert(db,"col");
+ if(index){
+ Document idx = new Document().Append("x", IndexOrder.Ascending);
+ db[name].MetaData.CreateIndex(idx,false);
+ }
+ TestInsert(name, db, col,doc);
+ }
+
+ public static void Main (string[] args)
+ {
+ SetupDocuments();
+
+ Mongo m = new Mongo();
+ m.Connect();
+ Database db = m["benchmark"];
+ db.MetaData.DropDatabase();
+
+ runInsertTest("insert (small, no index)", db, "small_none",small,false);
+ runInsertTest("insert (medium, no index)", db, "medium_none",medium,false);
+ runInsertTest("insert (large, no index)", db, "large_none",large,false);
+
+ runInsertTest("insert (small, indexed)", db, "small_index",small,true);
+ runInsertTest("insert (medium, indexed)", db, "medium_index",medium,true);
+ runInsertTest("insert (large, indexed)", db, "large_index",large,true);
+
+
+ }
+ }
+}
View
1  MongoDB.Driver.Benchmark/MongoDB.Driver.Benchmark.csproj
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?>
View
12 MongoDB.Linq.Tests/MongoDB.Linq.Tests.csproj
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -31,16 +31,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
+ <Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\redist\Moq.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=2.4.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <Reference Include="nunit.framework, Version=2.4.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\redist\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.configuration" />
+ <Reference Include="System.Configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
@@ -74,7 +74,7 @@
<Name>MongoDB.Driver</Name>
</ProjectReference>
</ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
View
6 MongoDB.Linq/MongoDB.Linq.csproj
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -61,7 +61,7 @@
<Name>MongoDB.Driver</Name>
</ProjectReference>
</ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
View
45 MongoDBDriver.sln
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver", "MongoDBDriver\MongoDB.Driver.csproj", "{B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}"
EndProject
-Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "Packages", "Packages.mdproj", "{502F3381-58AA-461B-B9D8-12578A588C61}"
+Project("{9344bdbb-3e7f-41fc-a0dd-8665d75ee146}") = "Packages", "Packages.mdproj", "{502F3381-58AA-461B-B9D8-12578A588C61}"
EndProject
-Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "MongoDBDriverTranslation", "MongoDBDriverTranslation\MongoDBDriverTranslation.mdproj", "{DCBE47DD-59A6-4212-AA4A-142838088B69}"
+Project("{9344bdbb-3e7f-41fc-a0dd-8665d75ee146}") = "MongoDBDriverTranslation", "MongoDBDriverTranslation\MongoDBDriverTranslation.mdproj", "{89828A32-BE79-4B3A-8605-0B32C06F942F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Tests", "MongoDB.Net-Tests\MongoDB.Driver.Tests.csproj", "{C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}"
EndProject
@@ -13,42 +13,43 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Linq", "MongoDB.Lin
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Linq.Tests", "MongoDB.Linq.Tests\MongoDB.Linq.Tests.csproj", "{870FE8E1-3461-4C79-BF25-9C35E41BF582}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.Driver.Benchmark", "MongoDB.Driver.Benchmark\MongoDB.Driver.Benchmark.csproj", "{5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Release|Any CPU.Build.0 = Release|Any CPU
- {502F3381-58AA-461B-B9D8-12578A588C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {502F3381-58AA-461B-B9D8-12578A588C61}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {502F3381-58AA-461B-B9D8-12578A588C61}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {502F3381-58AA-461B-B9D8-12578A588C61}.Release|Any CPU.Build.0 = Release|Any CPU
- {DCBE47DD-59A6-4212-AA4A-142838088B69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DCBE47DD-59A6-4212-AA4A-142838088B69}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DCBE47DD-59A6-4212-AA4A-142838088B69}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DCBE47DD-59A6-4212-AA4A-142838088B69}.Release|Any CPU.Build.0 = Release|Any CPU
- {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Release|Any CPU.Build.0 = Release|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {502F3381-58AA-461B-B9D8-12578A588C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {502F3381-58AA-461B-B9D8-12578A588C61}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}.Release|Any CPU.Build.0 = Release|Any CPU
{870FE8E1-3461-4C79-BF25-9C35E41BF582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{870FE8E1-3461-4C79-BF25-9C35E41BF582}.Debug|Any CPU.Build.0 = Debug|Any CPU
{870FE8E1-3461-4C79-BF25-9C35E41BF582}.Release|Any CPU.ActiveCfg = Release|Any CPU
{870FE8E1-3461-4C79-BF25-9C35E41BF582}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
+ {89828A32-BE79-4B3A-8605-0B32C06F942F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {89828A32-BE79-4B3A-8605-0B32C06F942F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- version = 0.1
StartupItem = MongoDBDriver\MongoDB.Driver.csproj
EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
EndGlobal
View
3  MongoDBDriver/DatabaseMetaData.cs
@@ -40,7 +40,8 @@ public class DatabaseMetaData
}
public Boolean DropDatabase(){
- throw new NotImplementedException();
+ Document result = db.SendCommand("dropDatabase");
+ return result.Contains("ok") && ((double)result["ok"] == 1);
}
public void AddUser(string username, string password){
View
3  MongoDBDriver/MongoDB.Driver.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -34,6 +34,7 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <RootNamespace>MongoDB.Driver</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
View
2  Packages.mdproj
@@ -8,7 +8,7 @@
<Packages>
<Packages>
<Package name="Tarball">
- <Builder TargetDirectory="/home/dev/Projects/MongoDBDriver/MongoDBDriver" DefaultConfiguration="Debug" ctype="TarballDeployTarget">
+ <Builder TargetDirectory="..\..\..\..\..\home\dev\Projects\MongoDBDriver\MongoDBDriver" DefaultConfiguration="Debug" ctype="TarballDeployTarget">
<ChildEntries>
<SolutionItemReference path="MongoDBDriver\MongoDBDriver.csproj" />
</ChildEntries>
Please sign in to comment.
Something went wrong with that request. Please try again.