2411: Add copyright notices to everything.
[arvados.git] / services / api / test / helpers / time_block.rb
index a3b03ff2ba91be22392895538e32733ce7a4bafe..6c444e2478dd8b46ce4df46d0a543c128c5d47cc 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class ActiveSupport::TestCase
   def time_block label
     t0 = Time.now
@@ -8,4 +12,16 @@ class ActiveSupport::TestCase
       $stderr.puts "#{t1 - t0}s #{label}"
     end
   end
+
+  def vmpeak c
+    open("/proc/self/status").each_line do |line|
+      print "Begin #{c} #{line}" if (line =~ /^VmHWM:/)
+    end
+    n = yield
+    open("/proc/self/status").each_line do |line|
+      print "End #{c} #{line}" if (line =~ /^VmHWM:/)
+    end
+    n
+  end
+
 end