diff --git a/BenchmarkTask.cpp b/BenchmarkTask.cpp
new file mode 100644
index 0000000..5ec249a
--- /dev/null
+++ b/BenchmarkTask.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BenchmarkTask.h"
+#include "BenchmarkGen.h"
+#include "VolumeManager.h"
+#include "ResponseCode.h"
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <cutils/iosched_policy.h>
+#include <hardware_legacy/power.h>
+#include <private/android_filesystem_config.h>
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+#define ENABLE_DROP_CACHES 1
+
+using android::base::ReadFileToString;
+using android::base::WriteStringToFile;
+
+namespace android {
+namespace vold {
+
+static const char* kWakeLock = "BenchmarkTask";
+
+BenchmarkTask::BenchmarkTask(const std::string& path,
+        const android::sp<android::os::IVoldTaskListener>& listener) :
+        mPath(path), mListener(listener) {
+}
+
+BenchmarkTask::~BenchmarkTask() {
+}
+
+void BenchmarkTask::start() {
+    mThread = std::thread(&BenchmarkTask::run, this);
+}
+
+static status_t runInternal(const std::string& rootPath, android::os::PersistableBundle& extras) {
+    auto path = rootPath;
+    path += "/misc";
+    if (android::vold::PrepareDir(path, 01771, AID_SYSTEM, AID_MISC)) {
+        return -1;
+    }
+    path += "/vold";
+    if (android::vold::PrepareDir(path, 0700, AID_ROOT, AID_ROOT)) {
+        return -1;
+    }
+    path += "/bench";
+    if (android::vold::PrepareDir(path, 0700, AID_ROOT, AID_ROOT)) {
+        return -1;
+    }
+
+    errno = 0;
+    int orig_prio = getpriority(PRIO_PROCESS, 0);
+    if (errno != 0) {
+        PLOG(ERROR) << "Failed to getpriority";
+        return -1;
+    }
+    if (setpriority(PRIO_PROCESS, 0, -10) != 0) {
+        PLOG(ERROR) << "Failed to setpriority";
+        return -1;
+    }
+
+    IoSchedClass orig_clazz = IoSchedClass_NONE;
+    int orig_ioprio = 0;
+    if (android_get_ioprio(0, &orig_clazz, &orig_ioprio)) {
+        PLOG(ERROR) << "Failed to android_get_ioprio";
+        return -1;
+    }
+    if (android_set_ioprio(0, IoSchedClass_RT, 0)) {
+        PLOG(ERROR) << "Failed to android_set_ioprio";
+        return -1;
+    }
+
+    char orig_cwd[PATH_MAX];
+    if (getcwd(orig_cwd, PATH_MAX) == NULL) {
+        PLOG(ERROR) << "Failed getcwd";
+        return -1;
+    }
+    if (chdir(path.c_str()) != 0) {
+        PLOG(ERROR) << "Failed chdir";
+        return -1;
+    }
+
+    sync();
+
+    LOG(INFO) << "Benchmarking " << path;
+    nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
+
+    BenchmarkCreate();
+    sync();
+    nsecs_t create = systemTime(SYSTEM_TIME_BOOTTIME);
+
+#if ENABLE_DROP_CACHES
+    LOG(VERBOSE) << "Before drop_caches";
+    if (!WriteStringToFile("3", "/proc/sys/vm/drop_caches")) {
+        PLOG(ERROR) << "Failed to drop_caches";
+    }
+    LOG(VERBOSE) << "After drop_caches";
+#endif
+    nsecs_t drop = systemTime(SYSTEM_TIME_BOOTTIME);
+
+    BenchmarkRun();
+    sync();
+    nsecs_t run = systemTime(SYSTEM_TIME_BOOTTIME);
+
+    BenchmarkDestroy();
+    sync();
+    nsecs_t destroy = systemTime(SYSTEM_TIME_BOOTTIME);
+
+    if (chdir(orig_cwd) != 0) {
+        PLOG(ERROR) << "Failed to chdir";
+    }
+    if (android_set_ioprio(0, orig_clazz, orig_ioprio)) {
+        PLOG(ERROR) << "Failed to android_set_ioprio";
+    }
+    if (setpriority(PRIO_PROCESS, 0, orig_prio) != 0) {
+        PLOG(ERROR) << "Failed to setpriority";
+    }
+
+    nsecs_t create_d = create - start;
+    nsecs_t drop_d = drop - create;
+    nsecs_t run_d = run - drop;
+    nsecs_t destroy_d = destroy - run;
+
+    LOG(INFO) << "create took " << nanoseconds_to_milliseconds(create_d) << "ms";
+    LOG(INFO) << "drop took " << nanoseconds_to_milliseconds(drop_d) << "ms";
+    LOG(INFO) << "run took " << nanoseconds_to_milliseconds(run_d) << "ms";
+    LOG(INFO) << "destroy took " << nanoseconds_to_milliseconds(destroy_d) << "ms";
+
+    extras.putString(String16("path"), String16(path.c_str()));
+    extras.putString(String16("ident"), String16(BenchmarkIdent().c_str()));
+    extras.putLong(String16("create"), create_d);
+    extras.putLong(String16("drop"), drop_d);
+    extras.putLong(String16("run"), run_d);
+    extras.putLong(String16("destroy"), destroy_d);
+
+    return 0;
+}
+
+void BenchmarkTask::run() {
+    acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
+
+    android::os::PersistableBundle extras;
+    status_t res = runInternal(mPath, extras);
+    if (mListener) {
+        mListener->onFinished(res, extras);
+    }
+
+    release_wake_lock(kWakeLock);
+}
+
+}  // namespace vold
+}  // namespace android
