Repository: pandas-dev/pandas

Issue:
PERF: asv's for non-int64 merges
in #28875 we enabled non-int64 merges between all integer types. I think we need asv's to see how performant these are: https://github.com/pandas-dev/pandas/pull/28875#issuecomment-541037953


Discussion:
pandas/asv_bench/benchmarks/join_merge.py  already has a method time_on_int32.

  def time_on_int32(self, direction):
            merge_asof(self.df1d, self.df2d, on="time32", direction=direction)
Not sure if this covers. Let me know it anything is needed.

hmm was this asv just not working before?

can u show these asvs here (pls run them)
I think the main thing to note in regards to #28875 is that the change there only affected situations in regards to merge_asof when a `tolerance`  value is set. Nothing changed on other merge cases.

None of the benchmarks currently defined here currently make use of this tolerance value, maybe that is something to add to the asv's? https://github.com/pandas-dev/pandas/blob/54b1151a5b8be5a59323faa1047685e90aad023e/asv_bench/benchmarks/join_merge.py#L317-L332

Would be willing to take this up on monday if nobody else wants to do it in the meantime

Resolving patch:
diff --git a/asv_bench/benchmarks/join_merge.py b/asv_bench/benchmarks/join_merge.py
--- a/asv_bench/benchmarks/join_merge.py
+++ b/asv_bench/benchmarks/join_merge.py
@@ -273,10 +273,10 @@ def time_merge_ordered(self):
 
 
 class MergeAsof:
-    params = [["backward", "forward", "nearest"]]
-    param_names = ["direction"]
+    params = [["backward", "forward", "nearest"], [None, 5]]
+    param_names = ["direction", "tolerance"]
 
-    def setup(self, direction):
+    def setup(self, direction, tolerance):
         one_count = 200000
         two_count = 1000000
 
@@ -303,6 +303,9 @@ def setup(self, direction):
         df1["time32"] = np.int32(df1.time)
         df2["time32"] = np.int32(df2.time)
 
+        df1["timeu64"] = np.uint64(df1.time)
+        df2["timeu64"] = np.uint64(df2.time)
+
         self.df1a = df1[["time", "value1"]]
         self.df2a = df2[["time", "value2"]]
         self.df1b = df1[["time", "key", "value1"]]
@@ -313,22 +316,52 @@ def setup(self, direction):
         self.df2d = df2[["time32", "value2"]]
         self.df1e = df1[["time", "key", "key2", "value1"]]
         self.df2e = df2[["time", "key", "key2", "value2"]]
+        self.df1f = df1[["timeu64", "value1"]]
+        self.df2f = df2[["timeu64", "value2"]]
+
+    def time_on_int(self, direction, tolerance):
+        merge_asof(
+            self.df1a, self.df2a, on="time", direction=direction, tolerance=tolerance
+        )
 
-    def time_on_int(self, direction):
-        merge_asof(self.df1a, self.df2a, on="time", direction=direction)
+    def time_on_int32(self, direction, tolerance):
+        merge_asof(
+            self.df1d, self.df2d, on="time32", direction=direction, tolerance=tolerance
+        )
 
-    def time_on_int32(self, direction):
-        merge_asof(self.df1d, self.df2d, on="time32", direction=direction)
+    def time_on_uint64(self, direction, tolerance):
+        merge_asof(
+            self.df1f, self.df2f, on="timeu64", direction=direction, tolerance=tolerance
+        )
 
-    def time_by_object(self, direction):
-        merge_asof(self.df1b, self.df2b, on="time", by="key", direction=direction)
+    def time_by_object(self, direction, tolerance):
+        merge_asof(
+            self.df1b,
+            self.df2b,
+            on="time",
+            by="key",
+            direction=direction,
+            tolerance=tolerance,
+        )
 
-    def time_by_int(self, direction):
-        merge_asof(self.df1c, self.df2c, on="time", by="key2", direction=direction)
+    def time_by_int(self, direction, tolerance):
+        merge_asof(
+            self.df1c,
+            self.df2c,
+            on="time",
+            by="key2",
+            direction=direction,
+            tolerance=tolerance,
+        )
 
-    def time_multiby(self, direction):
+    def time_multiby(self, direction, tolerance):
         merge_asof(
-            self.df1e, self.df2e, on="time", by=["key", "key2"], direction=direction
+            self.df1e,
+            self.df2e,
+            on="time",
+            by=["key", "key2"],
+            direction=direction,
+            tolerance=tolerance,
         )
 
 


Test patch: