Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CacheLine {
- public static final int CACHE_LINE_SIZE = 64;
- public static final int SIZE = 1024 * 1024 * 1024;
- public static void main(String[] args) {
- new CacheLine().run();
- }
- private void test(byte[] a, int step, int count) {
- long startTime = System.currentTimeMillis();
- for (int qq = 0; qq < 50; qq++) {
- for (int i = 0, pos = 0; i < count; i += 1, pos += step) {
- a[pos] += 1;
- }
- }
- long endTime = System.currentTimeMillis();
- System.err.println(String.format("Step %d, time %d ms", step, endTime - startTime));
- }
- private void run() {
- byte[] aaa = new byte[SIZE];
- int step = 4;
- for (int cstep = step; cstep < 512; cstep += step) {
- test(aaa, cstep, 1024 * 1024);
- }
- }
- }
- Step 4, time 38 ms
- Step 8, time 50 ms
- Step 12, time 61 ms
- Step 16, time 82 ms
- Step 20, time 104 ms
- Step 24, time 124 ms
- Step 28, time 150 ms
- Step 32, time 167 ms
- Step 36, time 189 ms
- Step 40, time 212 ms
- Step 44, time 233 ms
- Step 48, time 258 ms
- Step 52, time 283 ms
- Step 56, time 306 ms
- Step 60, time 331 ms
- Step 64, time 352 ms
- Step 68, time 362 ms
- Step 72, time 373 ms
- Step 76, time 380 ms
- Step 80, time 396 ms
- Step 84, time 410 ms
- Step 88, time 417 ms
- Step 92, time 427 ms
- Step 96, time 435 ms
- Step 100, time 446 ms
- Step 104, time 449 ms
- Step 108, time 454 ms
- Step 112, time 461 ms
- Step 116, time 462 ms
- Step 120, time 471 ms
- Step 124, time 494 ms
- Step 128, time 492 ms
- Step 132, time 475 ms
- Step 136, time 480 ms
- Step 140, time 477 ms
- Step 144, time 477 ms
- Step 148, time 478 ms
- Step 152, time 481 ms
- Step 156, time 473 ms
- Step 160, time 479 ms
- Step 164, time 477 ms
- Step 168, time 481 ms
- Step 172, time 480 ms
- Step 176, time 478 ms
- Step 180, time 477 ms
- Step 184, time 478 ms
- Step 188, time 483 ms
- Step 192, time 477 ms
- Step 196, time 477 ms
- Step 200, time 480 ms
- Step 204, time 481 ms
- Step 208, time 487 ms
- Step 212, time 477 ms
- Step 216, time 479 ms
- Step 220, time 482 ms
- Step 224, time 488 ms
- Step 228, time 482 ms
- Step 232, time 484 ms
- Step 236, time 532 ms
- Step 240, time 496 ms
- Step 244, time 491 ms
- Step 248, time 482 ms
- Step 252, time 493 ms
- Step 256, time 514 ms
- Step 260, time 512 ms
- Step 264, time 512 ms
- Step 268, time 519 ms
- Step 272, time 506 ms
- Step 276, time 505 ms
- Step 280, time 532 ms
- Step 284, time 516 ms
- Step 288, time 520 ms
- Step 292, time 514 ms
- Step 296, time 510 ms
- Step 300, time 537 ms
- Step 304, time 522 ms
- Step 308, time 554 ms
- Step 312, time 559 ms
- Step 316, time 549 ms
- Step 320, time 548 ms
- Step 324, time 546 ms
- Step 328, time 553 ms
- Step 332, time 567 ms
- Step 336, time 549 ms
- Step 340, time 546 ms
- Step 344, time 526 ms
- Step 348, time 526 ms
- Step 352, time 500 ms
- Step 356, time 504 ms
- Step 360, time 494 ms
- Step 364, time 493 ms
- Step 368, time 495 ms
- Step 372, time 463 ms
- Step 376, time 483 ms
- Step 380, time 481 ms
- Step 384, time 468 ms
- Step 388, time 466 ms
- Step 392, time 498 ms
- Step 396, time 476 ms
- Step 400, time 491 ms
- Step 404, time 502 ms
- Step 408, time 499 ms
- Step 412, time 468 ms
- Step 416, time 579 ms
- Step 420, time 552 ms
- Step 424, time 487 ms
- Step 428, time 470 ms
- Step 432, time 459 ms
- Step 436, time 466 ms
- Step 440, time 467 ms
- Step 444, time 462 ms
- Step 448, time 447 ms
- Step 452, time 460 ms
- Step 456, time 448 ms
- Step 460, time 427 ms
- Step 464, time 462 ms
- Step 468, time 463 ms
- Step 472, time 469 ms
- Step 476, time 465 ms
- Step 480, time 457 ms
- Step 484, time 467 ms
- Step 488, time 458 ms
- Step 492, time 469 ms
- Step 496, time 461 ms
- Step 500, time 459 ms
- Step 504, time 426 ms
- Step 508, time 469 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement