From 42e2eefc7fc59e9aee0a0a1b8c173420915401b4 Mon Sep 17 00:00:00 2001 From: danielshaya Date: Thu, 23 Apr 2015 13:22:41 +0100 Subject: [PATCH] Initial commit for FilePerMap implementation. --- .../openhft/chronicle/map/FilePerKeyMap.java | 8 +++--- .../chronicle/map/FilePerMapKeyTest.java | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/FilePerKeyMap.java b/src/main/java/net/openhft/chronicle/map/FilePerKeyMap.java index 67cb456d2..20ca46293 100644 --- a/src/main/java/net/openhft/chronicle/map/FilePerKeyMap.java +++ b/src/main/java/net/openhft/chronicle/map/FilePerKeyMap.java @@ -63,9 +63,9 @@ public class FilePerKeyMap implements ChronicleMap { Path p = dirPath.resolve(fileName); String mapVal = getFileContents(p); if(isProgrammaticUpdate(p.toFile())){ - System.out.println("Programmatic create to " + mapKey + " : " + mapVal); + System.out.println("Programmatic create to " + mapKey);// + " : " + mapVal); }else { - System.out.println("created " + mapKey + " : " + mapVal); + System.out.println("created " + mapKey);// + " : " + mapVal); } } else if (kind == StandardWatchEventKinds.ENTRY_DELETE) { Path p = dirPath.resolve(fileName); @@ -79,9 +79,9 @@ public class FilePerKeyMap implements ChronicleMap { Path p = dirPath.resolve(fileName); String mapVal = getFileContents(p); if(isProgrammaticUpdate(p.toFile())){ - System.out.println("Programmatic update to " + mapKey + " : " + mapVal); + System.out.println("Programmatic update to " + mapKey);// + " : " + mapVal); }else { - System.out.println("User modified " + mapKey + " : " + mapVal); + System.out.println("User modified " + mapKey + " : ");// + mapVal); } } } diff --git a/src/test/java/net/openhft/chronicle/map/FilePerMapKeyTest.java b/src/test/java/net/openhft/chronicle/map/FilePerMapKeyTest.java index 5e7228d3b..53efa63b1 100644 --- a/src/test/java/net/openhft/chronicle/map/FilePerMapKeyTest.java +++ b/src/test/java/net/openhft/chronicle/map/FilePerMapKeyTest.java @@ -119,4 +119,32 @@ public class FilePerMapKeyTest { } } + @Test + public void perfTest(){ + //There are no entries in the map so null should be returned + FilePerKeyMap map = new FilePerKeyMap<>("/tmp/filepermaptests"); + + //just in case it hasn't been cleared up last time + map.clear(); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 2_000_000; i++) { + sb.append('x'); + } + String value = sb.toString(); + + //warmup + for (int i = 0; i < 1000; i++) { + map.put("big file", value); + } + + + long time = System.currentTimeMillis(); + int iterations = 50; + for (int i = 0; i < iterations; i++) { + map.put("big file", value); + } + System.out.println("Time to update "+ iterations + " iterations " + (System.currentTimeMillis()-time)); + } + }