Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

10
LINES

< > BotCompany Repo | #1033107 // evaluateWithResourceUse

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4520L/25K).

static <A> WithSideValue<FunctionResourceUse, A> evaluateWithResourceUse(IF0<A> f) {
  long time1 = nanoTime();
  long value1 = bytesAllocatedByCurrentThread();
  A a = f?!;
  long value2 = bytesAllocatedByCurrentThread();
  long time2 = nanoTime();
  ret withSideValue(FunctionResourceUse()
    .bytesAllocated(value1 < 0 ? -1 : value2-value1)
    .runtime(nanosToSecondsObject(time2-time1)), a);
}

Author comment

Began life as a copy of #1033099

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033107
Snippet name: evaluateWithResourceUse
Eternal ID of this version: #1033107/3
Text MD5: 3296206dad697089e987a1cd73371384
Transpilation MD5: e7b14618c4b4fb8ca5fbc795c928b51b
Author: stefan
Category: javax / monitoring
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-14 16:44:36
Source code size: 408 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 98 / 213
Version history: 2 change(s)
Referenced in: [show references]