Permalink
Browse files

append improvment + update

  • Loading branch information...
1 parent 44d46fb commit 6b86f366f12ea13585e004e4f00547c3b7dbc168 @ptmt committed May 13, 2012
@@ -24,7 +24,7 @@ let inline testStraightWildcardSearch<'t> query =
//Kevo.Store.findByQuery<'t> query |> List.collect (fun x -> x.Syn)
let inline testDeserializeFromProtoBuf<'t> =
let c = Kevo.Core.getDictionary<'t>
- //let k = Kevo.ProtoBuf.deserialize<'t>
+ //let k = Kevo.ProtoBuf.deserialize<'t>
Kevo.ProtoBuf.serialize<Dictionary<int, 't>> c (string typeof<'t>.GUID)
Kevo.JsonNet.serialize<Dictionary<int, 't>> c
let b = Kevo.JsonNet.deserialize<Dictionary<int, 't>>
@@ -37,17 +37,14 @@ let inline testAppend c =
[0..c] |> List.map (fun x -> Kevo.Store.append<string>(x, (string x), None)) |> ignore
let perf = float c / timer.Elapsed.TotalMilliseconds
printfn "%i; %f" c perf
- Kevo.MemoryCache.clearCache Kevo.Core.cacheIndex<string>
- printfn "%A" Kevo.Core.getDictionary<string>.Count
-
+
let inline testUpdate c =
let timer = new System.Diagnostics.Stopwatch()
timer.Start()
[0..c] |> List.map (fun x -> Kevo.Store.update<string>(x, (string x))) |> ignore
let perf = float c / timer.Elapsed.TotalMilliseconds
printfn "%i; %f" c perf
- Kevo.MemoryCache.clearCache Kevo.Core.cacheIndex<string>
- printfn "%A" Kevo.Core.getDictionary<string>.Count
+
let testAppendLoop lmax step type_of_append=
@@ -67,9 +64,10 @@ let testAppendLoop lmax step type_of_append=
let testWrapper<'t> query =
- //testAppendLoop 100000 10000
+
testAppendLoop 100000 10000 "insert"
+ printfn "update"
testAppendLoop 100000 10000 "update"
-
+ printfn "ok"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -15,7 +15,7 @@ let getDictionary<'t> =
match a with
| null -> let b = deserialize<Dictionary<int, 't>> cacheIndex<'t>
(addToCache cacheIndex<'t> b)
- printfn "%A added to cache" cacheIndex<'t>
+ //printfn "%A added to cache" cacheIndex<'t>
b
| _ -> a :?> Dictionary<int, 't>
View
@@ -14,7 +14,7 @@ let serialize<'t> what where =
file.SetLength(file.Position); // fix truncated
file.Close())
stopWatch.Stop()
- printfn "Protobuf serialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
+ //printfn "Protobuf serialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
let deserialize<'t> from =
@@ -24,7 +24,7 @@ let deserialize<'t> from =
let c = Serializer.Deserialize<'t>(file);
file.Close()
stopWatch.Stop()
- printfn "Protobuf deserialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
+ //printfn "Protobuf deserialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
c
else
let t = System.Activator.CreateInstance(typeof<'t>)
View
@@ -1,9 +1,9 @@
#KeVo
-Damn Easy Key-Value Store written in F# 3.0.
+KeVo is a Damn Easy Key-Value Store written in F# 3.0. It is in-memory store using System.Runtime.MemoryCache with full synchronized append log.
+
+It serialize all objects in Protocol Buffers (Json.NET or binary serialization optional)
-- serializing all Object in Protocol Buffers or Json.NET
-- using System.Runtinme.MemoryCache
##Getting Started
@@ -13,13 +13,20 @@ Damn Easy Key-Value Store written in F# 3.0.
val findByQuery : ('t -> bool) -> 't list
-And function for insert items:
+insert items:
val append<'t> : int * 't * (unit -> unit) option -> unit
+update
+
+ val update<'t> : int * 't -> unit
+
##Create/insert
-By default if storage is not exist
+By default if storage is not exist `append` function create new file. For example, to insert any string in Dictionary<int, string> just use `append` function:
+
+ let add_string index =
+ Kevo.Store.append<string>(index, (index x), None)
##Read
@@ -42,21 +49,25 @@ To find any item by id, use findById:
Use predicate function for search by any templates:
let query (x:WordItem) =
- x.Wordst.Contains("ñëîâî")
+ x.Wordst.Contains("Local Street")
Kevo.Store.findByQuery<Address> query |> printfn "%A"
##Benchmarks
-Few tests from: `Kevo.Benchmark`
+Few tests from `Kevo.Benchmark`.
-For Intel Core i5 2500K / 16gb RAM:
+Test machine configuration is Intel Core i5 2500K / 16gb RAM:
Protobuf deserialization complete in 1431.623400 ms
Protobuf serialization complete in 311.327300 ms
Json.Net serialization complete in 1770.890400 ms
- Json.Net deserialization complete in 3060.234400 ms
- "Kevo.PerformanceTests+testWrapper@24[Kevo.Performance+WordItem]" Ellapsed Time: 2291.827700 ms
+ Json.Net deserialization complete in 3060.234400 ms
testReadSumAllNones 564674759
- "Kevo.PerformanceTests+testWrapper@25-3[Kevo.Performance+WordItem]" Ellapsed Time: 66.317000 ms
+
+
+### Append/Update
+
+
+![benchmark screenshot](https://github.com/unknownexception/kevo/raw/master/Kevo.Benchmarks/screenshot1.png)
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>87418c59-5cb5-4b9d-8db7-4622d302a77d</ProjectGuid>
- <OutputType>Library</OutputType>
- <RootNamespace>Kevo.Tests</RootNamespace>
- <AssemblyName>Kevo.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <Name>Kevo.Tests</Name>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <Tailcalls>false</Tailcalls>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <WarningLevel>3</WarningLevel>
- <DocumentationFile>bin\Debug\Kevo.Tests.XML</DocumentationFile>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <Tailcalls>true</Tailcalls>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <WarningLevel>3</WarningLevel>
- <DocumentationFile>bin\Release\Kevo.Tests.XML</DocumentationFile>
- </PropertyGroup>
- <PropertyGroup>
- <MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
- </PropertyGroup>
- <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
- <ItemGroup>
- <Compile Include="KevoTests.fs" />
- <None Include="packages.config" />
- </ItemGroup>
- <ItemGroup>
- <Reference Include="mscorlib" />
- <Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <Private>True</Private>
- </Reference>
- <Reference Include="nunit.framework">
- <HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
- <Private>True</Private>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Numerics" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Kevo.Core\Kevo.Core.fsproj">
- <Name>Kevo.Core</Name>
- <Project>{d5ae23dd-98bd-4a90-863c-4cc220e56e3e}</Project>
- <Private>True</Private>
- </ProjectReference>
- </ItemGroup>
- <!-- 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">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
View
@@ -1,52 +0,0 @@
-module Kevo.Tests
-
-open NUnit.Framework
-open Kevo.Store
-open System
-
-
-let shouldBeTrue a =
- Assert.AreEqual(a, true)
-
-
-let shouldBeFalse a =
- Assert.AreEqual(a, false)
-
-let checkFilesForType<'t> =
- System.IO.Directory.GetFiles(Kevo.AppendLog.dataPath) |> Array.filter (fun x -> x.Contains(string typeof<'t>))
-
-[<Test>]
-let ``kevo should be able to append some integer`` () =
- checkFilesForType<int> |> Array.map (fun x -> System.IO.File.Delete x) |> ignore
- Kevo.Store.append<int>(1, 1, None)
- checkFilesForType<int>.Length = 1 |> shouldBeTrue
-
-[<Test>]
-let ``kevo should be able to commit int`` () =
- let dict = Kevo.Core.getDictionary<int>
- let length_before = dict.Count
-
- let random_value = System.Random().Next()
- Kevo.AppendLog.appendSync<int> length_before random_value
- // just for for x.Contains(string DateTime.Now.Second) = false
- System.Threading.Thread.Sleep(1000)
- Kevo.AppendLog.commit<int> |> shouldBeTrue
- // file must be deleted
- let files = checkFilesForType<int>
- files.Length = 0 |> shouldBeTrue
- // dictionary must be with one more count
- Kevo.Core.getDictionary<int>.Count = 0 |> shouldBeFalse
- (Kevo.Core.getDictionary<int>.Count - length_before) = 1 |> shouldBeTrue
- Kevo.Core.getDictionary<int>.ContainsValue(random_value) |> shouldBeTrue
- // delete cache and try again
- Kevo.MemoryCache.clearCache Kevo.Core.cacheIndex<int>
- (Kevo.Core.getDictionary<int>.Count - length_before) = 1 |> shouldBeTrue
- Kevo.Core.getDictionary<int>.ContainsValue(random_value) |> shouldBeTrue
-
-[<Test>]
-let ``kevo should be correct process concurency commiting`` () =
- Kevo.Store.append<float32>(1, 1.0f, None)
- System.Threading.Thread.Sleep(1000)
- async { [1..10] |> List.map (fun x -> Kevo.AppendLog.commit<float32>) |> ignore } |> Async.RunSynchronously
-
- checkFilesForType<float32>.Length = 0 |> shouldBeTrue
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="NUnit" version="2.6.0.12054" />
-</packages>
View
@@ -37,7 +37,7 @@ let ``kevo should be able to commit int into memory and flush to disk`` () =
let random_value = System.Random(100).Next()
Kevo.AppendLog.appendSync<int> length_before random_value
- //System.Threading.Thread.Sleep(1000)
+
Kevo.AppendLog.commit<int> |> shouldBeTrue
// all files must be deleted

0 comments on commit 6b86f36

Please sign in to comment.