- Timestamp:
- 07/17/11 22:51:11 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/QAPAlgorithms/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence merged: 6356,6446,6548
- Property svn:mergeinfo changed
-
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r6342 r6569 39 39 using HeuristicLab.Persistence.Interfaces; 40 40 using Microsoft.VisualStudio.TestTools.UnitTesting; 41 using System.Threading.Tasks; 42 using HeuristicLab.Algorithms.GeneticAlgorithm; 41 43 42 44 namespace HeuristicLab.Persistence_33.Tests { … … 1271 1273 } 1272 1274 1273 1275 [TestMethod] 1276 public void ConcurrencyTest() { 1277 int n = 20; 1278 Task[] tasks = new Task[n]; 1279 for (int i = 0; i < n; i++) { 1280 tasks[i] = Task.Factory.StartNew((idx) => { 1281 byte[] data; 1282 using(var stream = new MemoryStream()) { 1283 XmlGenerator.Serialize(new GeneticAlgorithm(), stream); 1284 data = stream.ToArray(); 1285 } 1286 }, i); 1287 } 1288 Task.WaitAll(tasks); 1289 } 1290 1291 [TestMethod] 1292 public void ConcurrentBitmapTest() { 1293 Bitmap b = new Bitmap(300, 300); 1294 Random r = new Random(); 1295 for (int x = 0; x<b.Height; x++) { 1296 for (int y = 0; y<b.Width; y++) { 1297 b.SetPixel(x, y, Color.FromArgb(r.Next())); 1298 } 1299 } 1300 Task[] tasks = new Task[20]; 1301 byte[][] datas = new byte[tasks.Length][]; 1302 for (int i = 0; i<tasks.Length; i++) { 1303 tasks[i] = Task.Factory.StartNew((idx) => { 1304 using (var stream = new MemoryStream()) { 1305 XmlGenerator.Serialize(b, stream); 1306 datas[(int)idx] = stream.ToArray(); 1307 } 1308 }, i); 1309 } 1310 Task.WaitAll(tasks); 1311 } 1274 1312 1275 1313 [ClassInitialize]
Note: See TracChangeset
for help on using the changeset viewer.