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

15
LINES

< > BotCompany Repo | #1009316 // Benchmark Lock.lock() and lockInterruptibly() [I see 20,000,000+ lockings per second]

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

Libraryless. Click here for Pure Java version (640L/5K/18K).

!7

static int n = 1000000;
static Lock lock = lock();

p {
  repeat 10 {
    time "1 million uncontested lockings" {
      repeat n { lock lock(); }
    }
    time "1 million times uncontested .lock()" {
      repeat n { lock.lock(); lock.unlock(); }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1009316
Snippet name: Benchmark Lock.lock() and lockInterruptibly() [I see 20,000,000+ lockings per second]
Eternal ID of this version: #1009316/6
Text MD5: 364382fb809606a6549990fc5a019ee5
Transpilation MD5: 24957a2c2fba87e21c072d045fc790fb
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-19 18:40:01
Source code size: 277 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 381 / 501
Version history: 5 change(s)
Referenced in: [show references]