libtimeinstate: change map format to improve performance

By storing times for up to 32 freqs in each map value instead of one
time per value, we can drastically reduce the number of syscalls
required to get the data for a single UID and for all UIDs. This
translates into a better than 3x speedup in getUidsCpuFreqTimes().

Test: libtimeinstate_test passes
Bug: 138317993
Change-Id: I0d2d4d5fc99a82179a84a9aa83101bc55ddbc0e4
Signed-off-by: Connor O'Brien <connoro@google.com>
(cherry picked from commit 16ab1709fc9bef67fc1655128f54a6bce182de50)
Merged-In: I0d2d4d5fc99a82179a84a9aa83101bc55ddbc0e4
diff --git a/libs/cputimeinstate/testtimeinstate.cpp b/libs/cputimeinstate/testtimeinstate.cpp
index 6347de1..39007e4 100644
--- a/libs/cputimeinstate/testtimeinstate.cpp
+++ b/libs/cputimeinstate/testtimeinstate.cpp
@@ -126,10 +126,10 @@
         ASSERT_GE(fd, 0);
         time_key_t k;
         ASSERT_FALSE(getFirstMapKey(fd, &k));
-        val_t val;
-        ASSERT_FALSE(findMapEntry(fd, &k, &val));
+        std::vector<val_t> vals(get_nprocs_conf());
+        ASSERT_FALSE(findMapEntry(fd, &k, vals.data()));
         k.uid = uid;
-        ASSERT_FALSE(writeToMapEntry(fd, &k, &val, BPF_NOEXIST));
+        ASSERT_FALSE(writeToMapEntry(fd, &k, vals.data(), BPF_NOEXIST));
     }
     auto times = getUidCpuFreqTimes(uid);
     ASSERT_TRUE(times.has_value());