1 | using System.Threading.Tasks;
|
---|
2 |
|
---|
3 | namespace TestPooling {
|
---|
4 | using System;
|
---|
5 | using System.Collections.Generic;
|
---|
6 | using System.Diagnostics;
|
---|
7 | using System.Linq;
|
---|
8 | using System.Threading;
|
---|
9 | using DirtyList;
|
---|
10 |
|
---|
11 | using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
|
---|
12 | using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
|
---|
13 | using HeuristicLab.Problems.ProgramSynthesis.Push.Generators;
|
---|
14 | using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
|
---|
15 | using HeuristicLab.Problems.ProgramSynthesis.Push.Parser;
|
---|
16 | using HeuristicLab.Problems.ProgramSynthesis.Push.Simplifier;
|
---|
17 | using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
|
---|
18 | using HeuristicLab.Random;
|
---|
19 |
|
---|
20 | using TestPooling.Pool;
|
---|
21 |
|
---|
22 | class Program {
|
---|
23 | private const int PartitionSize = 512;
|
---|
24 | private const int ExampleCount = 200;
|
---|
25 | private const int InstanceCount = 1024;
|
---|
26 | private const int PopulationCount = 100;
|
---|
27 |
|
---|
28 | private static int TotalInstanceCount => PopulationCount * InstanceCount * ExampleCount;
|
---|
29 |
|
---|
30 | static void Main(string[] args) {
|
---|
31 | //Test1();
|
---|
32 | //Test1_2();
|
---|
33 | //Test3();
|
---|
34 |
|
---|
35 | //TestCollectionPooling();
|
---|
36 |
|
---|
37 | //DirtyListTest();
|
---|
38 |
|
---|
39 | //TestAddRangeNConcat();
|
---|
40 |
|
---|
41 | //TestStacks();
|
---|
42 |
|
---|
43 | //SimpleTest();
|
---|
44 | //Stepwise().Wait();
|
---|
45 | //PerformanceTestInterpreter();
|
---|
46 | //PerformanceParallelTestInterpreter();
|
---|
47 | //PerformanceTestLinearCodeGenerator();
|
---|
48 | TestRobustness();
|
---|
49 | //TestPool();
|
---|
50 | //TestPoolPerformance();
|
---|
51 | //TestSimplifier();
|
---|
52 | //FlagsTest();
|
---|
53 | //TestExpressionDependencies();
|
---|
54 |
|
---|
55 | Console.WriteLine("\nPress any key to continue...");
|
---|
56 | Console.ReadKey(false);
|
---|
57 | }
|
---|
58 |
|
---|
59 | private static void TestExpressionDependencies() {
|
---|
60 | var enabledExpressions = ExpressionTable.GetEnabledExpressionsByStackTypes(StackTypes.Boolean | StackTypes.Integer);
|
---|
61 | }
|
---|
62 |
|
---|
63 | private static void FlagsTest() {
|
---|
64 | var types = StackTypes.Boolean | StackTypes.Char | StackTypes.Integer;
|
---|
65 |
|
---|
66 | StackTypes test1 = (StackTypes)(StackTypes.Boolean - types);
|
---|
67 | StackTypes test2 = (StackTypes)((StackTypes.Boolean | StackTypes.Float) - types);
|
---|
68 | StackTypes test3 = ((StackTypes.Boolean | StackTypes.Float) & types);
|
---|
69 | StackTypes test4 = ((StackTypes.Boolean | StackTypes.Float) ^ types);
|
---|
70 | StackTypes test5 = ((StackTypes.Boolean | StackTypes.Float) | types);
|
---|
71 | StackTypes test6 = (StackTypes.Boolean | StackTypes.Float) & ~types;
|
---|
72 | StackTypes test7 = StackTypes.Boolean & ~types;
|
---|
73 | }
|
---|
74 |
|
---|
75 | private static void TestStacks() {
|
---|
76 | var sw = new Stopwatch();
|
---|
77 | var stack = new DirtyList.PushStack<int>();
|
---|
78 | var stack2 = new PushStack2<int>();
|
---|
79 | var stack3 = new PushStack3<int>();
|
---|
80 | var listC = new List<int>(1000);
|
---|
81 | var count = 200000;
|
---|
82 | var repeats = 10;
|
---|
83 |
|
---|
84 | for (var i = 0; i < 100; i++) {
|
---|
85 | listC.Add(i);
|
---|
86 | }
|
---|
87 |
|
---|
88 | sw.Start();
|
---|
89 | for (var j = 0; j < repeats; j++) {
|
---|
90 | stack.Clear();
|
---|
91 |
|
---|
92 | for (int i = 0; i < count; i++) {
|
---|
93 | stack.Push(listC);
|
---|
94 | }
|
---|
95 | }
|
---|
96 | sw.Stop();
|
---|
97 |
|
---|
98 | Console.WriteLine("{0}", sw.ElapsedMilliseconds / repeats);
|
---|
99 |
|
---|
100 | sw.Restart();
|
---|
101 | for (var j = 0; j < repeats; j++) {
|
---|
102 | stack2.Clear();
|
---|
103 |
|
---|
104 | for (int i = 0; i < count; i++) {
|
---|
105 | stack2.PushRange(listC);
|
---|
106 | }
|
---|
107 | }
|
---|
108 | sw.Stop();
|
---|
109 |
|
---|
110 | Console.WriteLine("{0}", sw.ElapsedMilliseconds / repeats);
|
---|
111 |
|
---|
112 | sw.Restart();
|
---|
113 | for (var j = 0; j < repeats; j++) {
|
---|
114 | stack3.Clear();
|
---|
115 |
|
---|
116 | for (int i = 0; i < count; i++) {
|
---|
117 | stack3.PushRange(listC);
|
---|
118 | }
|
---|
119 | }
|
---|
120 | sw.Stop();
|
---|
121 |
|
---|
122 | Console.WriteLine("{0}", sw.ElapsedMilliseconds / repeats);
|
---|
123 |
|
---|
124 | sw.Restart();
|
---|
125 | for (int i = 0; i < count * listC.Count; i++) {
|
---|
126 | stack.Pop();
|
---|
127 | }
|
---|
128 |
|
---|
129 | Console.WriteLine("{0}", sw.ElapsedMilliseconds);
|
---|
130 |
|
---|
131 | sw.Restart();
|
---|
132 | for (int i = 0; i < count * listC.Count; i++) {
|
---|
133 | stack2.Pop();
|
---|
134 | }
|
---|
135 |
|
---|
136 | Console.WriteLine("{0}", sw.ElapsedMilliseconds);
|
---|
137 |
|
---|
138 |
|
---|
139 | }
|
---|
140 |
|
---|
141 | private static void TestAddRangeNConcat() {
|
---|
142 | var sw = new Stopwatch();
|
---|
143 | var count = 10000;
|
---|
144 | var listA = new List<int>();
|
---|
145 | var listB = new List<int>();
|
---|
146 | var listC = new List<int>(1000);
|
---|
147 |
|
---|
148 | for (var i = 0; i < 1000; i++) {
|
---|
149 | listC.Add(i);
|
---|
150 | }
|
---|
151 |
|
---|
152 | sw.Start();
|
---|
153 | for (int i = 0; i < count; i++) {
|
---|
154 | listA.AddRange(listC);
|
---|
155 | }
|
---|
156 | sw.Stop();
|
---|
157 |
|
---|
158 | Console.WriteLine("{0}", sw.ElapsedMilliseconds);
|
---|
159 |
|
---|
160 | sw.Restart();
|
---|
161 | for (int i = 0; i < count; i++) {
|
---|
162 | listB = listB.Concat(listC).ToList();
|
---|
163 | }
|
---|
164 | sw.Stop();
|
---|
165 |
|
---|
166 | Console.WriteLine("{0}", sw.ElapsedMilliseconds);
|
---|
167 |
|
---|
168 | }
|
---|
169 |
|
---|
170 | private static void DirtyListTest() {
|
---|
171 | var sw = new Stopwatch();
|
---|
172 | var provider = new ManagedPoolProvider<Person>(100, () => new Person());
|
---|
173 | var provider2 = new ManagedPoolProvider<Person>(100, () => new Person());
|
---|
174 | var dl = new DirtyList<Person>();
|
---|
175 | var l = new List<Person>();
|
---|
176 |
|
---|
177 | sw.Start();
|
---|
178 | for (var i = 0; i < 30000000; i++) {
|
---|
179 | using (var pool = provider.CreatePool()) {
|
---|
180 | for (var j = 0; j < 2; j++) {
|
---|
181 | var person = pool.Get();
|
---|
182 | person.Age = i + j;
|
---|
183 | person.Name = (i + j).ToString();
|
---|
184 |
|
---|
185 | dl.Add(person);
|
---|
186 | }
|
---|
187 | }
|
---|
188 |
|
---|
189 | dl.Clear();
|
---|
190 | }
|
---|
191 | sw.Stop();
|
---|
192 |
|
---|
193 | Console.WriteLine("DirtyList: {0}", sw.Elapsed.TotalSeconds);
|
---|
194 |
|
---|
195 | sw.Restart();
|
---|
196 | for (var i = 0; i < 30000000; i++) {
|
---|
197 | using (var pool = provider2.CreatePool()) {
|
---|
198 | for (var j = 0; j < 2; j++) {
|
---|
199 | var person = pool.Get();
|
---|
200 | person.Age = i + j;
|
---|
201 | person.Name = (i + j).ToString();
|
---|
202 |
|
---|
203 | l.Add(person);
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 | l.Clear();
|
---|
208 | }
|
---|
209 | sw.Stop();
|
---|
210 |
|
---|
211 | Console.WriteLine("List: {0}", sw.Elapsed.TotalSeconds);
|
---|
212 | }
|
---|
213 |
|
---|
214 | private static void TestCollectionPooling() {
|
---|
215 | var sw = new Stopwatch();
|
---|
216 | sw.Start();
|
---|
217 |
|
---|
218 | var provider = new ManagedPoolProvider<PooledList<Person>>(PartitionSize, () => new PooledList<Person>());
|
---|
219 |
|
---|
220 | Parallel.For(0, PopulationCount, pc => {
|
---|
221 | for (var e = 0; e < ExampleCount; e++) {
|
---|
222 | using (var pool = provider.CreatePool()) {
|
---|
223 | var list = pool.Get();
|
---|
224 |
|
---|
225 | for (var i = 0; i < InstanceCount; i++)
|
---|
226 | list.Add(new Person {
|
---|
227 | Age = pc + e + i,
|
---|
228 | Name = string.Format("{0} - {1} - {2}", pc, e, i)
|
---|
229 | });
|
---|
230 | }
|
---|
231 | }
|
---|
232 | });
|
---|
233 | sw.Stop();
|
---|
234 |
|
---|
235 | Console.WriteLine("Collection Pooling - Duration: {0} - {1} for {2}/{3} instances", sw.ElapsedTicks, sw.Elapsed.TotalSeconds, provider.InstanceCount, TotalInstanceCount);
|
---|
236 | }
|
---|
237 |
|
---|
238 |
|
---|
239 | private static void Test1() {
|
---|
240 | var sw = new Stopwatch();
|
---|
241 |
|
---|
242 | sw.Start();
|
---|
243 | Parallel.For(0, PopulationCount, pc => {
|
---|
244 | for (var e = 0; e < ExampleCount; e++) {
|
---|
245 | using (var pool = new ManagedPool<Person>(PartitionSize, () => new Person())) {
|
---|
246 | for (var i = 0; i < InstanceCount; i++) {
|
---|
247 | var person = pool.Get();
|
---|
248 | person.Age = pc + e + i;
|
---|
249 | person.Name = string.Format("{0} - {1} - {2}", pc, e, i);
|
---|
250 | }
|
---|
251 | }
|
---|
252 | }
|
---|
253 | });
|
---|
254 | sw.Stop();
|
---|
255 |
|
---|
256 | Console.WriteLine("1 - Duration: {0} - {1} for {2}/{3} instances", sw.ElapsedTicks, sw.Elapsed.TotalSeconds, ManagedPool<Person>.InstanceCount, TotalInstanceCount);
|
---|
257 | }
|
---|
258 |
|
---|
259 | private static void Test1_2() {
|
---|
260 | var sw = new Stopwatch();
|
---|
261 | sw.Start();
|
---|
262 |
|
---|
263 | var provider = new ManagedPoolProvider<Person>(PartitionSize, () => new Person());
|
---|
264 |
|
---|
265 | Parallel.For(0, PopulationCount, pc => {
|
---|
266 | for (var e = 0; e < ExampleCount; e++) {
|
---|
267 | using (var pool = provider.CreatePool()) {
|
---|
268 | for (var i = 0; i < InstanceCount; i++) {
|
---|
269 | var person = pool.Get();
|
---|
270 | person.Age = pc + e + i;
|
---|
271 | person.Name = string.Format("{0} - {1} - {2}", pc, e, i);
|
---|
272 | }
|
---|
273 | }
|
---|
274 | }
|
---|
275 | });
|
---|
276 | sw.Stop();
|
---|
277 |
|
---|
278 | Console.WriteLine("1_2 - Duration: {0} - {1} for {2}/{3} instances", sw.ElapsedTicks, sw.Elapsed.TotalSeconds, provider.InstanceCount, TotalInstanceCount);
|
---|
279 | }
|
---|
280 |
|
---|
281 | private static void Test3() {
|
---|
282 | var count = 0;
|
---|
283 | var sw = new Stopwatch();
|
---|
284 |
|
---|
285 | sw.Start();
|
---|
286 | Parallel.For(0, PopulationCount, pc => {
|
---|
287 | for (var e = 0; e < ExampleCount; e++) {
|
---|
288 | var list = new Person[InstanceCount];
|
---|
289 | for (var i = 0; i < InstanceCount; i++) {
|
---|
290 | list[i] = new Person {
|
---|
291 | Age = pc + e + i,
|
---|
292 | Name = string.Format("{0} - {1} - {2}", pc, e, i)
|
---|
293 | };
|
---|
294 | }
|
---|
295 |
|
---|
296 | Interlocked.Add(ref count, list.Length);
|
---|
297 | }
|
---|
298 | });
|
---|
299 | sw.Stop();
|
---|
300 |
|
---|
301 | Console.WriteLine("3 - Duration: {0} - {1}", sw.ElapsedTicks, sw.Elapsed.TotalSeconds);
|
---|
302 | Console.WriteLine("PartitionSize: {0}", count);
|
---|
303 | }
|
---|
304 |
|
---|
305 | private static void Test2() {
|
---|
306 | var pool = new ObjectPool<Person>(() => new Person(), 2048);
|
---|
307 |
|
---|
308 | Parallel.For(0, 10000, i => {
|
---|
309 | for (var j = 0; j < 3000; j++) {
|
---|
310 | var person = pool.Allocate();
|
---|
311 | person.Age = i + j;
|
---|
312 | person.Name = string.Format("{0} - {1}", i, j);
|
---|
313 | }
|
---|
314 |
|
---|
315 | //pool.Free()
|
---|
316 | });
|
---|
317 | }
|
---|
318 |
|
---|
319 | static void SimpleTest() {
|
---|
320 | var interpreter = new PushInterpreter();
|
---|
321 |
|
---|
322 | interpreter.Run("5 INTEGER.DUP INTEGER.+");
|
---|
323 |
|
---|
324 | interpreter.PrintStacks();
|
---|
325 | }
|
---|
326 |
|
---|
327 | static async Task Stepwise() {
|
---|
328 | var interpreter = new PushInterpreter();
|
---|
329 |
|
---|
330 | interpreter.RunAsync("( 0 2 CODE.QUOTE ( 1 INTEGER.+ 0 3 CODE.QUOTE ( 1 INTEGER.+ INTEGER.* ) CODE.DO*RANGE INTEGER.+ ) CODE.DO*RANGE )", true).Wait();
|
---|
331 |
|
---|
332 | while (!interpreter.IsCompleted) {
|
---|
333 | Console.Clear();
|
---|
334 | interpreter.PrintStacks();
|
---|
335 | interpreter.Step();
|
---|
336 |
|
---|
337 | var input = Console.ReadKey();
|
---|
338 | if (input.Key == ConsoleKey.Escape) {
|
---|
339 | break;
|
---|
340 | } else if (input.Key == ConsoleKey.Spacebar) {
|
---|
341 | await interpreter.ResumeAsync();
|
---|
342 | }
|
---|
343 | }
|
---|
344 |
|
---|
345 | Console.Clear();
|
---|
346 | interpreter.PrintStacks();
|
---|
347 | }
|
---|
348 |
|
---|
349 | static void PerformanceTestInterpreter() {
|
---|
350 | var program = PushParser.Parse("( 5 INTEGER.DUP INTEGER.+ )");
|
---|
351 |
|
---|
352 | var interpreter = new PushInterpreter();
|
---|
353 | var sw = new Stopwatch();
|
---|
354 |
|
---|
355 | sw.Start();
|
---|
356 | for (var i = 0; i < 60000000; i++) {
|
---|
357 | interpreter.Run(program);
|
---|
358 | interpreter.Clear();
|
---|
359 | }
|
---|
360 | sw.Stop();
|
---|
361 |
|
---|
362 | Console.WriteLine(sw.Elapsed);
|
---|
363 | }
|
---|
364 |
|
---|
365 | static void PerformanceParallelTestInterpreter() {
|
---|
366 | var program = PushParser.Parse("( 5 INTEGER.DUP INTEGER.+ )");
|
---|
367 |
|
---|
368 | var sw = new Stopwatch();
|
---|
369 | var iterations = 100;
|
---|
370 | var amount = 600000;
|
---|
371 | var pool = new PushInterpreterPool(iterations, 1024);
|
---|
372 |
|
---|
373 | sw.Start();
|
---|
374 | Parallel.For(0, iterations, i => {
|
---|
375 | using (var interpreter = pool.Create()) {
|
---|
376 | for (var j = 0; j < amount; j++) {
|
---|
377 | interpreter.Run(program);
|
---|
378 | interpreter.Clear();
|
---|
379 | }
|
---|
380 | }
|
---|
381 | });
|
---|
382 | sw.Stop();
|
---|
383 |
|
---|
384 | Console.WriteLine(sw.Elapsed);
|
---|
385 | }
|
---|
386 |
|
---|
387 | static void PerformanceTestRecursiveCodeGenerator() {
|
---|
388 | var sw = new Stopwatch();
|
---|
389 | var random = new FastRandom(1337);
|
---|
390 |
|
---|
391 | sw.Start();
|
---|
392 | var expressions = RecursiveCodeGenerator.RandomCode(60000000, random).ToList();
|
---|
393 | sw.Stop();
|
---|
394 |
|
---|
395 | Console.WriteLine("Generated {0} in {1}", expressions.Count, sw.Elapsed);
|
---|
396 | }
|
---|
397 |
|
---|
398 | static void PerformanceTestLinearCodeGenerator() {
|
---|
399 | var sw = new Stopwatch();
|
---|
400 | var random = new FastRandom(1337);
|
---|
401 | var poolProvider = new ManagedPoolProvider<PooledList<Expression>>(65636, () => new PooledList<Expression>());
|
---|
402 |
|
---|
403 | sw.Start();
|
---|
404 | var expressions = LinearCodeGenerator.RandomCode(60000000, null, random).ToList();
|
---|
405 | sw.Stop();
|
---|
406 |
|
---|
407 | Console.WriteLine("Generated {0} in {1}", expressions.Count, sw.Elapsed);
|
---|
408 | }
|
---|
409 |
|
---|
410 | static void TestRobustness() {
|
---|
411 | var sw = new Stopwatch();
|
---|
412 | var parallelism = Environment.ProcessorCount;
|
---|
413 | var maxProgramSizeLimit = 1024;
|
---|
414 | var partitionSize = 100000;
|
---|
415 | var execCounters = new int[parallelism];
|
---|
416 |
|
---|
417 | var config = new PushConfiguration {
|
---|
418 | EvalPushLimit = 1024,
|
---|
419 | MaxPointsInProgram = 1024,
|
---|
420 | IsCodeStackEnabled = false,
|
---|
421 | IsExecStackEnabled = false,
|
---|
422 | IsBooleanStackEnabled = false,
|
---|
423 | IsFloatStackEnabled = false,
|
---|
424 | IsIntegerStackEnabled = false,
|
---|
425 | IsNameStackEnabled = false,
|
---|
426 | };
|
---|
427 |
|
---|
428 | config.DisableExpression<ExecYExpression>();
|
---|
429 |
|
---|
430 | var pool = new PushInterpreterPool(config);
|
---|
431 |
|
---|
432 | sw.Start();
|
---|
433 | Parallel.For(0, parallelism, i => {
|
---|
434 | var random = new FastRandom(1337);
|
---|
435 |
|
---|
436 | using (var interpreter = pool.Create(random)) {
|
---|
437 | for (var j = 0; j < partitionSize; j++) {
|
---|
438 | var program = LinearCodeGenerator.RandomProgram(maxProgramSizeLimit, random, config);
|
---|
439 | interpreter.Run(program);
|
---|
440 |
|
---|
441 | execCounters[i] += interpreter.ExecCounter;
|
---|
442 | interpreter.Clear();
|
---|
443 | }
|
---|
444 | }
|
---|
445 | });
|
---|
446 | sw.Stop();
|
---|
447 |
|
---|
448 | Console.WriteLine("ExecCount: {0}", execCounters.Sum());
|
---|
449 | Console.WriteLine("Duration: {0}", sw.Elapsed);
|
---|
450 | }
|
---|
451 |
|
---|
452 | static void TestPool() {
|
---|
453 | var pool = new PushInterpreterPool();
|
---|
454 | var normal = new PushInterpreter();
|
---|
455 | int id;
|
---|
456 |
|
---|
457 | using (var interpreter = pool.Create()) {
|
---|
458 | interpreter.Run("( 1 2 INTEGER.+ )");
|
---|
459 |
|
---|
460 | id = interpreter.GetHashCode();
|
---|
461 | if (id == normal.GetHashCode()) Console.WriteLine("equal 1");
|
---|
462 | }
|
---|
463 |
|
---|
464 | using (var interpreter = pool.Create())
|
---|
465 | using (var interpreter2 = pool.Create()) {
|
---|
466 | interpreter.Run("( 1 2 INTEGER.+ )");
|
---|
467 | if (id == interpreter.GetHashCode()) Console.WriteLine("equal 2");
|
---|
468 | if (id == interpreter2.GetHashCode()) Console.WriteLine("equal 3");
|
---|
469 | }
|
---|
470 | }
|
---|
471 |
|
---|
472 | static void TestPoolPerformance() {
|
---|
473 | var sw = new Stopwatch();
|
---|
474 | var iterations = 100000000;
|
---|
475 |
|
---|
476 | sw.Start();
|
---|
477 | for (var i = 0; i < iterations; i++) {
|
---|
478 | var interpreter = new PushInterpreter();
|
---|
479 | interpreter.Clear();
|
---|
480 | }
|
---|
481 | sw.Stop();
|
---|
482 |
|
---|
483 | Console.WriteLine(sw.Elapsed);
|
---|
484 |
|
---|
485 | var pool = new PushInterpreterPool();
|
---|
486 | sw.Restart();
|
---|
487 | for (var i = 0; i < iterations; i++) {
|
---|
488 | using (var interpreter = pool.Create()) {
|
---|
489 | interpreter.Clear();
|
---|
490 | }
|
---|
491 | }
|
---|
492 | sw.Stop();
|
---|
493 |
|
---|
494 | Console.WriteLine(sw.Elapsed);
|
---|
495 | }
|
---|
496 |
|
---|
497 | static void TestSimplifier() {
|
---|
498 | var program = PushParser.ParseProgram("( 5 ( INTEGER.DUP FLOAT.+ FLOAT.- ) ( EXEC.DO ( EXEC.IF ) EXEC.Y ) INTEGER.+ )");
|
---|
499 | var pool = new PushInterpreterPool();
|
---|
500 | var random = new FastRandom(1337);
|
---|
501 |
|
---|
502 | var randomProg = LinearCodeGenerator.RandomProgram(4096 * 4, random); // 53
|
---|
503 |
|
---|
504 | Func<PushProgram, double> evaluator = prog => {
|
---|
505 | using (var interpreter = pool.Create(random)) {
|
---|
506 | interpreter.Run(prog);
|
---|
507 | return interpreter.IntegerStack.IsEmpty
|
---|
508 | ? double.MaxValue
|
---|
509 | : Math.Abs(interpreter.IntegerStack.Top - 10);
|
---|
510 | }
|
---|
511 | };
|
---|
512 |
|
---|
513 | var simplerProgram = Simplifier.Simplify(program, evaluator);
|
---|
514 |
|
---|
515 | Console.WriteLine(simplerProgram);
|
---|
516 | }
|
---|
517 | }
|
---|
518 |
|
---|
519 | [Serializable]
|
---|
520 | class Person : IPooledObject {
|
---|
521 | public string Name { get; set; }
|
---|
522 | public int Age { get; set; }
|
---|
523 |
|
---|
524 | public void Reset() {
|
---|
525 | Age = default(int);
|
---|
526 | Name = null;
|
---|
527 | }
|
---|
528 | }
|
---|
529 | }
|
---|