From a3577117a4b57694fb51beca49d93d163c7a4613 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 10 Nov 2017 11:07:38 -0800 Subject: [PATCH] Expose disable_sync_to_disk() via an env variable This makes core not actually flush data to disk when durability is not needed, such as when running tests. Doesn't help much for realm-js since the bulk of the time in them is spent waiting for things to time out, but it cuts the run time of the ROS tests in half. --- src/js_realm.cpp | 4 ++-- src/js_realm.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js_realm.cpp b/src/js_realm.cpp index 97024c81..687603aa 100644 --- a/src/js_realm.cpp +++ b/src/js_realm.cpp @@ -35,7 +35,7 @@ std::string default_path() { s_default_path = realm::default_realm_file_directory() + #if defined(WIN32) && WIN32 '\\' -#else +#else '/' #endif + "default.realm"; @@ -105,6 +105,6 @@ std::string TypeErrorException::type_string(Property const& prop) return ret; } - + } // js } // realm diff --git a/src/js_realm.hpp b/src/js_realm.hpp index bfe11141..db192cbf 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -44,6 +44,8 @@ #include "platform.hpp" #include "results.hpp" +#include + namespace realm { namespace js { @@ -343,6 +345,10 @@ inline typename T::Function RealmClass::create_constructor(ContextType ctx) { Object::set_property(ctx, realm_constructor, "Sync", sync_constructor, attributes); #endif + if (getenv("REALM_DISABLE_SYNC_TO_DISK")) { + realm::disable_sync_to_disk(); + } + Object::set_global(ctx, "Realm", realm_constructor); return realm_constructor; }