cleanup:Rename IBenchmarkService#readFile to measureReadRate

This CL renames IBenchmarkService#readFile to measureReadRate to make
the code more clear when introducing new read method later for authfs.

Test: atest MicrodroidBenchmarks
Change-Id: I1e39063ec704fcefb96f7d307e6598d291443645
diff --git a/tests/aidl/com/android/microdroid/testservice/IBenchmarkService.aidl b/tests/aidl/com/android/microdroid/testservice/IBenchmarkService.aidl
index e34c4b0..260f804 100644
--- a/tests/aidl/com/android/microdroid/testservice/IBenchmarkService.aidl
+++ b/tests/aidl/com/android/microdroid/testservice/IBenchmarkService.aidl
@@ -20,8 +20,12 @@
 interface IBenchmarkService {
     const int SERVICE_PORT = 5677;
 
-    /** Reads a file and returns the elapsed seconds for the reading. */
-    double readFile(String filename, long fileSizeBytes, boolean isRand);
+    /**
+     * Measures the read rate for reading the given file.
+     *
+     * @return The read rate in MB/s.
+     */
+    double measureReadRate(String filename, long fileSizeBytes, boolean isRand);
 
     /** Returns an entry from /proc/meminfo. */
     long getMemInfoEntry(String name);
diff --git a/tests/benchmark/Android.bp b/tests/benchmark/Android.bp
index bf78202..f1aebd2 100644
--- a/tests/benchmark/Android.bp
+++ b/tests/benchmark/Android.bp
@@ -29,7 +29,7 @@
 cc_library_shared {
     name: "MicrodroidBenchmarkNativeLib",
     srcs: ["src/native/benchmarkbinary.cpp"],
-    static_libs: ["libiovsock_vm"],
+    static_libs: ["libiobenchmark"],
     shared_libs: [
         "android.system.virtualmachineservice-ndk",
         "com.android.microdroid.testservice-ndk",
@@ -41,7 +41,7 @@
 }
 
 cc_library {
-    name: "libiovsock_vm",
+    name: "libiobenchmark",
     srcs: ["src/native/io_vsock.cpp"],
     export_include_dirs: ["src/native/include"],
     shared_libs: [
diff --git a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
index cdaf70c..7bf3c4e 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -268,9 +268,8 @@
         @Override
         public void onPayloadReady(VirtualMachine vm, IBenchmarkService benchmarkService)
                 throws RemoteException {
-            double elapsedSeconds = benchmarkService.readFile(FILENAME, mFileSizeBytes, mIsRand);
-            double fileSizeMb = mFileSizeBytes / SIZE_MB;
-            mReadRates.add(fileSizeMb / elapsedSeconds);
+            double readRate = benchmarkService.measureReadRate(FILENAME, mFileSizeBytes, mIsRand);
+            mReadRates.add(readRate);
         }
     }
 
diff --git a/tests/benchmark/src/native/benchmarkbinary.cpp b/tests/benchmark/src/native/benchmarkbinary.cpp
index 28799c8..58b4cf0 100644
--- a/tests/benchmark/src/native/benchmarkbinary.cpp
+++ b/tests/benchmark/src/native/benchmarkbinary.cpp
@@ -42,6 +42,7 @@
 
 namespace {
 constexpr uint64_t kBlockSizeBytes = 4096;
+constexpr uint64_t kNumBytesPerMB = 1024 * 1024;
 
 template <typename T>
 static ndk::ScopedAStatus resultStatus(const T& result) {
@@ -56,9 +57,9 @@
 
 class IOBenchmarkService : public aidl::com::android::microdroid::testservice::BnBenchmarkService {
 public:
-    ndk::ScopedAStatus readFile(const std::string& filename, int64_t fileSizeBytes, bool isRand,
-                                double* out) override {
-        auto res = read_file(filename, fileSizeBytes, isRand);
+    ndk::ScopedAStatus measureReadRate(const std::string& filename, int64_t fileSizeBytes,
+                                       bool isRand, double* out) override {
+        auto res = measure_read_rate(filename, fileSizeBytes, isRand);
         if (res.ok()) {
             *out = res.value();
         }
@@ -90,8 +91,9 @@
     }
 
 private:
-    /** Returns the elapsed seconds for reading the file. */
-    Result<double> read_file(const std::string& filename, int64_t fileSizeBytes, bool is_rand) {
+    /** Measures the read rate for reading the given file. */
+    Result<double> measure_read_rate(const std::string& filename, int64_t fileSizeBytes,
+                                     bool is_rand) {
         const int64_t block_count = fileSizeBytes / kBlockSizeBytes;
         std::vector<uint64_t> offsets;
         if (is_rand) {
@@ -120,7 +122,9 @@
                 return ErrnoError() << "failed to read";
             }
         }
-        return {((double)clock() - start) / CLOCKS_PER_SEC};
+        double elapsed_seconds = ((double)clock() - start) / CLOCKS_PER_SEC;
+        double read_rate = (double)fileSizeBytes / kNumBytesPerMB / elapsed_seconds;
+        return {read_rate};
     }
 
     Result<size_t> read_meminfo_entry(const std::string& stat) {