Index: perf/go/util/util.go |
diff --git a/perf/go/util/util.go b/perf/go/util/util.go |
index 24d350d8b15992625d3f54a1e3322aafee463e6c..04bb06885670125106b835051f0da414f06918f2 100644 |
--- a/perf/go/util/util.go |
+++ b/perf/go/util/util.go |
@@ -46,3 +46,23 @@ func MapsEqual(a, b map[string]string) bool { |
} |
return true |
} |
+ |
+// This is sad, but apparently there is no library function to get the absolute |
+// value of an int. |
+func AbsInt(v int) int { |
+ if v < 0 { |
+ return -v |
+ } |
+ return v |
+} |
+ |
+// Returns -1, 1 or 0 depending on the sign of v. |
+func SignInt(v int) int { |
+ if v < 0 { |
+ return -1 |
+ } |
+ if v > 0 { |
+ return 1 |
+ } |
+ return 0 |
+} |