/Xtensive.Core/Xtensive.Core.Tests/DotNetFramework/CoreFeaturesTest.cs

https://code.google.com/p/dataobjectsdotnet/ · C# · 728 lines · 704 code · 13 blank · 11 comment · 46 complexity · 415d1d15145b8534829df4d6038a0e04 MD5 · raw file

  1. // Copyright (C) 2003-2010 Xtensive LLC.
  2. // All rights reserved.
  3. // For conditions of distribution and use, see license.
  4. // Created by: Alex Yakunin
  5. // Created: 2008.04.17
  6. using System;
  7. using System.Collections.Generic;
  8. using NUnit.Framework;
  9. using Xtensive.Core.Diagnostics;
  10. using Xtensive.Core.Testing;
  11. namespace Xtensive.Core.Tests.DotNetFramework
  12. {
  13. [TestFixture]
  14. public class CoreFeaturesTest
  15. {
  16. public const int IterationCount = 100000000;
  17. public const int KSize = 1024;
  18. public const int MSize = KSize*1024;
  19. public const int SizeMin = 8 * KSize;
  20. public const int SizeMax = 16 * MSize;
  21. [Test]
  22. [Explicit]
  23. [Category("Performance")]
  24. public void PeformanceTest()
  25. {
  26. Test(1);
  27. }
  28. [Test]
  29. public void RegularTest()
  30. {
  31. Test(0.01);
  32. }
  33. private void Test(double speedFactor)
  34. {
  35. // Warmup
  36. TestInt32(100, true);
  37. TestInt64(100, true);
  38. TestDouble(100, true);
  39. TestCast(100, true);
  40. TestArray(100, true);
  41. TestList(100, true);
  42. TestDictionary(100, true);
  43. // Actual tests
  44. int count = (int)(IterationCount * speedFactor);
  45. int sizeMax = TestInfo.IsPerformanceTestRunning ? SizeMax : SizeMax / 8;
  46. TestInt32(count, false);
  47. TestInt64(count, false);
  48. TestDouble(count, false);
  49. TestCast(count, false);
  50. for (int size = SizeMin; size<=sizeMax; size *= 2) {
  51. TestArray(size, false);
  52. TestList(size, false);
  53. TestDictionary(size, false);
  54. }
  55. }
  56. private void TestInt32(int count, bool warmup)
  57. {
  58. using (warmup ? EmptyDisposable() : Log.InfoRegion("int operations")) {
  59. int j = 0;
  60. using (warmup ? EmptyDisposable() : Log.InfoRegion("Unchecked")) unchecked{
  61. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  62. new Measurement("Empty loop", MeasurementOptions.Log, count)) {
  63. for (int i = 0; i < count; i++) {
  64. }
  65. }
  66. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  67. new Measurement("Increment int", MeasurementOptions.Log, count)) {
  68. for (int i = 0; i < count; i+=10) {
  69. j++;
  70. j++;
  71. j++;
  72. j++;
  73. j++;
  74. j++;
  75. j++;
  76. j++;
  77. j++;
  78. j++;
  79. }
  80. }
  81. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  82. new Measurement("Adding int", MeasurementOptions.Log, count)) {
  83. for (int i = 0; i < count; i+=10) {
  84. j = j + 10;
  85. j = j + 10;
  86. j = j + 10;
  87. j = j + 10;
  88. j = j + 10;
  89. j = j + 10;
  90. j = j + 10;
  91. j = j + 10;
  92. j = j + 10;
  93. j = j + 10;
  94. }
  95. }
  96. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  97. new Measurement("Multiplying int", MeasurementOptions.Log, count)) {
  98. for (int i = 0; i < count; i+=10) {
  99. j = i * 0;
  100. j = j * 3;
  101. j = j * 3;
  102. j = j * 3;
  103. j = j * 3;
  104. j = j * 3;
  105. j = j * 3;
  106. j = j * 3;
  107. j = j * 3;
  108. j = j * 3;
  109. }
  110. }
  111. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  112. new Measurement("Dividing int", MeasurementOptions.Log, count)) {
  113. for (int i = 0; i < count; i+=10) {
  114. j = i / 3;
  115. j = j / 3;
  116. j = j / 3;
  117. j = j / 3;
  118. j = j / 3;
  119. j = j / 3;
  120. j = j / 3;
  121. j = j / 3;
  122. j = j / 3;
  123. j = j / 3;
  124. }
  125. }
  126. }
  127. using (warmup ? EmptyDisposable() : Log.InfoRegion("Checked")) checked{
  128. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  129. new Measurement("Empty loop", MeasurementOptions.Log, count)) {
  130. for (int i = 0; i < count; i++) {
  131. }
  132. }
  133. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  134. new Measurement("Increment int", MeasurementOptions.Log, count)) {
  135. for (int i = 0; i < count; i+=10) {
  136. j++;
  137. j++;
  138. j++;
  139. j++;
  140. j++;
  141. j++;
  142. j++;
  143. j++;
  144. j++;
  145. j++;
  146. }
  147. }
  148. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  149. new Measurement("Adding int", MeasurementOptions.Log, count)) {
  150. for (int i = 0; i < count; i+=10) {
  151. j = j + 10;
  152. j = j + 10;
  153. j = j + 10;
  154. j = j + 10;
  155. j = j + 10;
  156. j = j + 10;
  157. j = j + 10;
  158. j = j + 10;
  159. j = j + 10;
  160. j = j + 10;
  161. }
  162. }
  163. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  164. new Measurement("Multiplying int", MeasurementOptions.Log, count)) {
  165. for (int i = 0; i < count; i+=10) {
  166. j = i * 0;
  167. j = j * 3;
  168. j = j * 3;
  169. j = j * 3;
  170. j = j * 3;
  171. j = j * 3;
  172. j = j * 3;
  173. j = j * 3;
  174. j = j * 3;
  175. j = j * 3;
  176. }
  177. }
  178. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  179. new Measurement("Dividing int", MeasurementOptions.Log, count)) {
  180. for (int i = 0; i < count; i+=10) {
  181. j = i / 3;
  182. j = j / 3;
  183. j = j / 3;
  184. j = j / 3;
  185. j = j / 3;
  186. j = j / 3;
  187. j = j / 3;
  188. j = j / 3;
  189. j = j / 3;
  190. j = j / 3;
  191. }
  192. }
  193. }
  194. }
  195. }
  196. private void TestInt64(int count, bool warmup)
  197. {
  198. using (warmup ? EmptyDisposable() : Log.InfoRegion("long operations")) {
  199. long j = 0;
  200. using (warmup ? EmptyDisposable() : Log.InfoRegion("Unchecked")) unchecked{
  201. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  202. new Measurement("Empty loop", MeasurementOptions.Log, count)) {
  203. for (long i = 0; i < count; i++) {
  204. }
  205. }
  206. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  207. new Measurement("Increment long", MeasurementOptions.Log, count)) {
  208. for (int i = 0; i < count; i+=10) {
  209. j++;
  210. j++;
  211. j++;
  212. j++;
  213. j++;
  214. j++;
  215. j++;
  216. j++;
  217. j++;
  218. j++;
  219. }
  220. }
  221. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  222. new Measurement("Adding long", MeasurementOptions.Log, count)) {
  223. for (long i = 0; i < count; i+=10) {
  224. j = j + 10;
  225. j = j + 10;
  226. j = j + 10;
  227. j = j + 10;
  228. j = j + 10;
  229. j = j + 10;
  230. j = j + 10;
  231. j = j + 10;
  232. j = j + 10;
  233. j = j + 10;
  234. }
  235. }
  236. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  237. new Measurement("Multiplying long", MeasurementOptions.Log, count)) {
  238. for (long i = 0; i < count; i+=10) {
  239. j = (long)i * 3;
  240. j = j * 3;
  241. j = j * 3;
  242. j = j * 3;
  243. j = j * 3;
  244. j = j * 3;
  245. j = j * 3;
  246. j = j * 3;
  247. j = j * 3;
  248. j = j * 3;
  249. }
  250. }
  251. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  252. new Measurement("Dividing long", MeasurementOptions.Log, count)) {
  253. for (long i = 0; i < count; i+=10) {
  254. j = (long)i / 3;
  255. j = j / 3;
  256. j = j / 3;
  257. j = j / 3;
  258. j = j / 3;
  259. j = j / 3;
  260. j = j / 3;
  261. j = j / 3;
  262. j = j / 3;
  263. j = j / 3;
  264. }
  265. }
  266. }
  267. using (warmup ? EmptyDisposable() : Log.InfoRegion("Checked")) checked{
  268. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  269. new Measurement("Empty loop", MeasurementOptions.Log, count)) {
  270. for (long i = 0; i < count; i++) {
  271. }
  272. }
  273. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  274. new Measurement("Increment long", MeasurementOptions.Log, count)) {
  275. for (int i = 0; i < count; i+=10) {
  276. j++;
  277. j++;
  278. j++;
  279. j++;
  280. j++;
  281. j++;
  282. j++;
  283. j++;
  284. j++;
  285. j++;
  286. }
  287. }
  288. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  289. new Measurement("Adding long", MeasurementOptions.Log, count)) {
  290. for (long i = 0; i < count; i+=10) {
  291. j = j + 10;
  292. j = j + 10;
  293. j = j + 10;
  294. j = j + 10;
  295. j = j + 10;
  296. j = j + 10;
  297. j = j + 10;
  298. j = j + 10;
  299. j = j + 10;
  300. j = j + 10;
  301. }
  302. }
  303. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  304. new Measurement("Multiplying long", MeasurementOptions.Log, count)) {
  305. for (long i = 0; i < count; i+=10) {
  306. j = (long)i * 3;
  307. j = j * 3;
  308. j = j * 3;
  309. j = j * 3;
  310. j = j * 3;
  311. j = j * 3;
  312. j = j * 3;
  313. j = j * 3;
  314. j = j * 3;
  315. j = j * 3;
  316. }
  317. }
  318. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  319. new Measurement("Dividing long", MeasurementOptions.Log, count)) {
  320. for (long i = 0; i < count; i+=10) {
  321. j = (long)i / 3;
  322. j = j / 3;
  323. j = j / 3;
  324. j = j / 3;
  325. j = j / 3;
  326. j = j / 3;
  327. j = j / 3;
  328. j = j / 3;
  329. j = j / 3;
  330. j = j / 3;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. private void TestDouble(int count, bool warmup)
  337. {
  338. using (warmup ? EmptyDisposable() : Log.InfoRegion("double operations")) {
  339. double j = 0;
  340. using (warmup ? EmptyDisposable() : Log.InfoRegion("Unchecked")) unchecked{
  341. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  342. new Measurement("Adding double", MeasurementOptions.Log, count)) {
  343. for (int i = 0; i < count; i+=10) {
  344. j = j + 10.0;
  345. j = j + 10.0;
  346. j = j + 10.0;
  347. j = j + 10.0;
  348. j = j + 10.0;
  349. j = j + 10.0;
  350. j = j + 10.0;
  351. j = j + 10.0;
  352. j = j + 10.0;
  353. j = j + 10.0;
  354. }
  355. }
  356. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  357. new Measurement("Multiplying double", MeasurementOptions.Log, count)) {
  358. for (int i = 0; i < count; i+=10) {
  359. j = (double)i * 1.0000000000001;
  360. j = j * 1.0000000000001;
  361. j = j * 1.0000000000001;
  362. j = j * 1.0000000000001;
  363. j = j * 1.0000000000001;
  364. j = j * 1.0000000000001;
  365. j = j * 1.0000000000001;
  366. j = j * 1.0000000000001;
  367. j = j * 1.0000000000001;
  368. j = j * 1.0000000000001;
  369. }
  370. }
  371. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  372. new Measurement("Dividing double", MeasurementOptions.Log, count)) {
  373. for (int i = 0; i < count; i+=10) {
  374. j = (double)i / 1.0000000000001;
  375. j = j / 1.0000000000001;
  376. j = j / 1.0000000000001;
  377. j = j / 1.0000000000001;
  378. j = j / 1.0000000000001;
  379. j = j / 1.0000000000001;
  380. j = j / 1.0000000000001;
  381. j = j / 1.0000000000001;
  382. j = j / 1.0000000000001;
  383. j = j / 1.0000000000001;
  384. }
  385. }
  386. }
  387. using (warmup ? EmptyDisposable() : Log.InfoRegion("Checked")) checked{
  388. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  389. new Measurement("Adding double", MeasurementOptions.Log, count)) {
  390. for (int i = 0; i < count; i+=10) {
  391. j = j + 10.0;
  392. j = j + 10.0;
  393. j = j + 10.0;
  394. j = j + 10.0;
  395. j = j + 10.0;
  396. j = j + 10.0;
  397. j = j + 10.0;
  398. j = j + 10.0;
  399. j = j + 10.0;
  400. j = j + 10.0;
  401. }
  402. }
  403. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  404. new Measurement("Multiplying double", MeasurementOptions.Log, count)) {
  405. for (int i = 0; i < count; i+=10) {
  406. j = (double)i * 1.0000000000001;
  407. j = j * 1.0000000000001;
  408. j = j * 1.0000000000001;
  409. j = j * 1.0000000000001;
  410. j = j * 1.0000000000001;
  411. j = j * 1.0000000000001;
  412. j = j * 1.0000000000001;
  413. j = j * 1.0000000000001;
  414. j = j * 1.0000000000001;
  415. j = j * 1.0000000000001;
  416. }
  417. }
  418. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  419. new Measurement("Dividing double", MeasurementOptions.Log, count)) {
  420. for (int i = 0; i < count; i+=10) {
  421. j = (double)i / 1.0000000000001;
  422. j = j / 1.0000000000001;
  423. j = j / 1.0000000000001;
  424. j = j / 1.0000000000001;
  425. j = j / 1.0000000000001;
  426. j = j / 1.0000000000001;
  427. j = j / 1.0000000000001;
  428. j = j / 1.0000000000001;
  429. j = j / 1.0000000000001;
  430. j = j / 1.0000000000001;
  431. }
  432. }
  433. }
  434. }
  435. }
  436. private IDisposable EmptyDisposable()
  437. {
  438. return new Disposing.Disposable(delegate { });
  439. }
  440. private void TestCast(int size, bool warmup)
  441. {
  442. size = size / 10 * 10;
  443. // Test
  444. object o = EmptyDisposable();
  445. object t;
  446. Disposing.Disposable d = null;
  447. IDisposable id = null;
  448. TestHelper.CollectGarbage();
  449. using (warmup ? EmptyDisposable() : Log.InfoRegion("Casts")) {
  450. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  451. new Measurement("Box int ", MeasurementOptions.Log, size)) {
  452. for (int i = 0; i < size; ) {
  453. t = i++;
  454. t = i++;
  455. t = i++;
  456. t = i++;
  457. t = i++;
  458. t = i++;
  459. t = i++;
  460. t = i++;
  461. t = i++;
  462. t = i++;
  463. }
  464. }
  465. TestHelper.CollectGarbage();
  466. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  467. new Measurement("To ancestor ", MeasurementOptions.Log, size)) {
  468. for (int i = 0; i < size; i+=10) {
  469. d = (Disposing.Disposable)o;
  470. d = (Disposing.Disposable)o;
  471. d = (Disposing.Disposable)o;
  472. d = (Disposing.Disposable)o;
  473. d = (Disposing.Disposable)o;
  474. d = (Disposing.Disposable)o;
  475. d = (Disposing.Disposable)o;
  476. d = (Disposing.Disposable)o;
  477. d = (Disposing.Disposable)o;
  478. d = (Disposing.Disposable)o;
  479. }
  480. }
  481. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  482. new Measurement("To interface", MeasurementOptions.Log, size)) {
  483. for (int i = 0; i < size; i+=10) {
  484. id = (IDisposable)o;
  485. id = (IDisposable)o;
  486. id = (IDisposable)o;
  487. id = (IDisposable)o;
  488. id = (IDisposable)o;
  489. id = (IDisposable)o;
  490. id = (IDisposable)o;
  491. id = (IDisposable)o;
  492. id = (IDisposable)o;
  493. id = (IDisposable)o;
  494. }
  495. }
  496. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  497. new Measurement("To ancestor (as)", MeasurementOptions.Log, size)) {
  498. for (int i = 0; i < size; i+=10) {
  499. d = o as Disposing.Disposable;
  500. d = o as Disposing.Disposable;
  501. d = o as Disposing.Disposable;
  502. d = o as Disposing.Disposable;
  503. d = o as Disposing.Disposable;
  504. d = o as Disposing.Disposable;
  505. d = o as Disposing.Disposable;
  506. d = o as Disposing.Disposable;
  507. d = o as Disposing.Disposable;
  508. d = o as Disposing.Disposable;
  509. }
  510. }
  511. using (warmup ? (IDisposable) new Disposing.Disposable(delegate { }) :
  512. new Measurement("To interface (as)", MeasurementOptions.Log, size)) {
  513. for (int i = 0; i < size; i+=10) {
  514. id = o as IDisposable;
  515. id = o as IDisposable;
  516. id = o as IDisposable;
  517. id = o as IDisposable;
  518. id = o as IDisposable;
  519. id = o as IDisposable;
  520. id = o as IDisposable;
  521. id = o as IDisposable;
  522. id = o as IDisposable;
  523. id = o as IDisposable;
  524. }
  525. }
  526. }
  527. }
  528. private void TestArray(int size, bool warmup)
  529. {
  530. size = size / 10 * 10;
  531. int[] ints = new int[size];
  532. IEnumerable<int> eInts = ints;
  533. for (int i = 0; i < size; i++)
  534. ints[i] = i;
  535. // Test
  536. TestHelper.CollectGarbage();
  537. int j = size;
  538. using (warmup ? EmptyDisposable() : Log.InfoRegion(string.Format("int array, {0,6}K", (size+10) / KSize))) {
  539. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  540. new Measurement("Filling (x10)", MeasurementOptions.Log, size)) {
  541. for (int i = 0; i < size; ) {
  542. ints[i++] = i;
  543. ints[i++] = i;
  544. ints[i++] = i;
  545. ints[i++] = i;
  546. ints[i++] = i;
  547. ints[i++] = i;
  548. ints[i++] = i;
  549. ints[i++] = i;
  550. ints[i++] = i;
  551. ints[i++] = i;
  552. }
  553. }
  554. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  555. new Measurement("Filling (x1) ", MeasurementOptions.Log, size)) {
  556. for (int i = 0; i < size; i++) {
  557. ints[i] = i;
  558. }
  559. }
  560. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  561. new Measurement("Reading (x10)", MeasurementOptions.Log, size)) {
  562. for (int i = 0; i < size; ) {
  563. j = ints[i++];
  564. j = ints[i++];
  565. j = ints[i++];
  566. j = ints[i++];
  567. j = ints[i++];
  568. j = ints[i++];
  569. j = ints[i++];
  570. j = ints[i++];
  571. j = ints[i++];
  572. j = ints[i++];
  573. }
  574. }
  575. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  576. new Measurement("Reading (x1) ", MeasurementOptions.Log, size)) {
  577. for (int i = 0; i < size; ) {
  578. j = ints[i++];
  579. }
  580. }
  581. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  582. new Measurement("Enumerating ", MeasurementOptions.Log, size)) {
  583. foreach (int k in eInts) {
  584. }
  585. }
  586. }
  587. ints = null;
  588. TestHelper.CollectGarbage();
  589. }
  590. private void TestList(int size, bool warmup)
  591. {
  592. size = size / 10 * 10;
  593. List<int> ints = new List<int>(size);
  594. IEnumerable<int> eInts = ints;
  595. for (int i = 0; i < size; i++)
  596. ints.Add(i);
  597. // Test
  598. TestHelper.CollectGarbage();
  599. int j = size;
  600. using (warmup ? EmptyDisposable() : Log.InfoRegion(string.Format("int list, {0,6}K", (size+10) / KSize))) {
  601. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  602. new Measurement("Filling (x10)", MeasurementOptions.Log, size)) {
  603. for (int i = 0; i < size; ) {
  604. ints[i++] = i;
  605. ints[i++] = i;
  606. ints[i++] = i;
  607. ints[i++] = i;
  608. ints[i++] = i;
  609. ints[i++] = i;
  610. ints[i++] = i;
  611. ints[i++] = i;
  612. ints[i++] = i;
  613. ints[i++] = i;
  614. }
  615. }
  616. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  617. new Measurement("Filling (x1) ", MeasurementOptions.Log, size)) {
  618. for (int i = 0; i < size; i++) {
  619. ints[i] = i;
  620. }
  621. }
  622. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  623. new Measurement("Reading (x10)", MeasurementOptions.Log, size)) {
  624. for (int i = 0; i < size; ) {
  625. j = ints[i++];
  626. j = ints[i++];
  627. j = ints[i++];
  628. j = ints[i++];
  629. j = ints[i++];
  630. j = ints[i++];
  631. j = ints[i++];
  632. j = ints[i++];
  633. j = ints[i++];
  634. j = ints[i++];
  635. }
  636. }
  637. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  638. new Measurement("Reading (x1) ", MeasurementOptions.Log, size)) {
  639. for (int i = 0; i < size; ) {
  640. j = ints[i++];
  641. }
  642. }
  643. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  644. new Measurement("Enumerating ", MeasurementOptions.Log, size)) {
  645. foreach (int k in eInts) {
  646. }
  647. }
  648. }
  649. ints = null;
  650. TestHelper.CollectGarbage();
  651. }
  652. private void TestDictionary(int size, bool warmup)
  653. {
  654. size = size / 10 * 10;
  655. Dictionary<int, int> ints = new Dictionary<int, int>(size);
  656. IEnumerable<KeyValuePair<int, int>> eInts = ints;
  657. // Test
  658. TestHelper.CollectGarbage();
  659. int j = size;
  660. using (warmup ? EmptyDisposable() : Log.InfoRegion(string.Format("int dictionary, {0,6}K", (size+10) / KSize))) {
  661. ints.Clear();
  662. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  663. new Measurement("Filling (x10)", MeasurementOptions.Log, size)) {
  664. for (int i = 0; i < size; ) {
  665. ints[i++] = i;
  666. ints[i++] = i;
  667. ints[i++] = i;
  668. ints[i++] = i;
  669. ints[i++] = i;
  670. ints[i++] = i;
  671. ints[i++] = i;
  672. ints[i++] = i;
  673. ints[i++] = i;
  674. ints[i++] = i;
  675. }
  676. }
  677. ints.Clear();
  678. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  679. new Measurement("Filling (x1) ", MeasurementOptions.Log, size)) {
  680. for (int i = 0; i < size; i++) {
  681. ints[i] = i;
  682. }
  683. }
  684. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  685. new Measurement("Reading (x10)", MeasurementOptions.Log, size)) {
  686. for (int i = 0; i < size; ) {
  687. j = ints[i++];
  688. j = ints[i++];
  689. j = ints[i++];
  690. j = ints[i++];
  691. j = ints[i++];
  692. j = ints[i++];
  693. j = ints[i++];
  694. j = ints[i++];
  695. j = ints[i++];
  696. j = ints[i++];
  697. }
  698. }
  699. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  700. new Measurement("Reading (x1) ", MeasurementOptions.Log, size)) {
  701. for (int i = 0; i < size; ) {
  702. j = ints[i++];
  703. }
  704. }
  705. using (warmup ? (IDisposable)new Disposing.Disposable(delegate { }) :
  706. new Measurement("Enumerating ", MeasurementOptions.Log, size)) {
  707. foreach (KeyValuePair<int, int> k in eInts) {
  708. }
  709. }
  710. }
  711. ints = null;
  712. TestHelper.CollectGarbage();
  713. }
  714. }
  715. }