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

30
LINES

< > BotCompany Repo | #1011712 // Benchmark setOpt with _SetField (26 ns)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (1028L/7K).

!7

sclass MyClass implements _SetField {
  S a, b, c, d, e, f;
  
  public void _setField(S f, O x) {
    if (f.equals('a)) a = (S) x;
    else if (f.equals('b)) b = (S) x;
    else if (f.equals('c)) c = (S) x;
    else if (f.equals('d)) d = (S) x;
    else if (f.equals('e)) e = (S) x;
    else if (f.equals('f)) f = (S) x;
  }
}

sclass MyOtherClass {}

static volatile new MyClass c;

p {
  setOpt(new MyOtherClass, 'a, 0); // just to fill setOpt's cache
  
  int n = tenMillion();
  repeat 10 { time {
    repeat n {
      setOpt(c, 'e, "hello");
    }
  }}
  printBenchResult(n);
}

Author comment

Began life as a copy of #1011708

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011712
Snippet name: Benchmark setOpt with _SetField (26 ns)
Eternal ID of this version: #1011712/3
Text MD5: 180b695aa0ce876ce65b8adb4a02e4fd
Transpilation MD5: 408366f4257819a5b9007fd8e7b82f36
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-02 19:05:43
Source code size: 616 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 472 / 1030
Version history: 2 change(s)
Referenced in: [show references]