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

48
LINES

< > BotCompany Repo | #1005581 // Benchmark getOpt + cached version

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

Libraryless. Click here for Pure Java version (654L/5K/16K).

!752

sclass A {
  int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8;
}

sclass B {
  int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8;
  int i = 9, j = 10, k = 11, l = 12, m = 13, n = 14;
}

static final long rep = 1000000;

static S[] letters = new S[27];

!include #1005583 // getOpt_cached

p {
  new A a;
  new B b;
  
  for (int i = 1; i <= 26; i++)
    letters[i] = str(alphabetLetter(i));
  
  twice {
    time {
      for (long j = 0; j < rep; j++) {
        for (int i = 1; i <= 8; i++) {
          // Be mean - alternate between classes (different fields, same name)
          assertTrue(i == (Int) getOpt(a, letters[i]));
          assertTrue(i == (Int) getOpt(b, letters[i]));
        }
      }
    }
    
    time {
      for (long j = 0; j < rep; j++) {
        for (int i = 1; i <= 8; i++) {
          assertTrue(i == (Int) getOpt_cached(a, letters[i]));
          assertTrue(i == (Int) getOpt_cached(b, letters[i]));
        }
      }
    }
    
    long ms = getLastTiming();
    print(iterationsPerSecond(rep*8, ms) + " getOpt/s");
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005581
Snippet name: Benchmark getOpt + cached version
Eternal ID of this version: #1005581/1
Text MD5: 9292bebeb123086aa26aec05be730a18
Transpilation MD5: 4d981388979b5a911379198ead1ebebf
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-28 19:11:28
Source code size: 1122 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 503 / 623
Referenced in: #1005586 - Benchmark getDeclaredFields + getDeclaredFields_cached