Changeset 151 for MicroThreading/Demo
- Timestamp:
- Jan 27, 2011, 8:05:33 AM (14 years ago)
- Location:
- MicroThreading/Demo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r150 r151 47 47 <TopLine Value="1"/> 48 48 <CursorPos X="5" Y="9"/> 49 <UsageCount Value=" 59"/>49 <UsageCount Value="62"/> 50 50 </Unit0> 51 51 <Unit1> … … 55 55 <ResourceBaseClass Value="Form"/> 56 56 <UnitName Value="UMainForm"/> 57 <IsVisibleTab Value="True"/>58 57 <EditorIndex Value="0"/> 59 58 <WindowIndex Value="0"/> 60 <TopLine Value="2 49"/>61 <CursorPos X=" 22" Y="267"/>62 <UsageCount Value=" 59"/>59 <TopLine Value="252"/> 60 <CursorPos X="1" Y="274"/> 61 <UsageCount Value="62"/> 63 62 <Loaded Value="True"/> 64 63 <LoadedDesigner Value="True"/> … … 67 66 <Filename Value="../UMicroThreading.pas"/> 68 67 <UnitName Value="UMicroThreading"/> 68 <IsVisibleTab Value="True"/> 69 69 <EditorIndex Value="1"/> 70 70 <WindowIndex Value="0"/> 71 <TopLine Value="2 71"/>72 <CursorPos X="1" Y="2 86"/>73 <UsageCount Value="3 3"/>71 <TopLine Value="258"/> 72 <CursorPos X="1" Y="271"/> 73 <UsageCount Value="34"/> 74 74 <Loaded Value="True"/> 75 75 </Unit2> … … 406 406 <Filename Value="../UPlatform.pas"/> 407 407 <UnitName Value="UPlatform"/> 408 <EditorIndex Value=" 3"/>408 <EditorIndex Value="2"/> 409 409 <WindowIndex Value="0"/> 410 410 <TopLine Value="1"/> 411 411 <CursorPos X="24" Y="9"/> 412 <UsageCount Value="1 3"/>412 <UsageCount Value="14"/> 413 413 <Loaded Value="True"/> 414 414 </Unit48> … … 430 430 <Unit51> 431 431 <Filename Value="../../../../lazarus/lcl/interfaces/gtk2/gtk2widgetset.inc"/> 432 <EditorIndex Value="2"/>433 432 <WindowIndex Value="0"/> 434 433 <TopLine Value="2380"/> 435 434 <CursorPos X="30" Y="2390"/> 436 435 <UsageCount Value="10"/> 437 <Loaded Value="True"/>438 436 </Unit51> 439 437 <Unit52> … … 477 475 <Position1> 478 476 <Filename Value="../UMicroThreading.pas"/> 479 <Caret Line=" 308" Column="1" TopLine="284"/>477 <Caret Line="257" Column="1" TopLine="241"/> 480 478 </Position1> 481 479 <Position2> 482 480 <Filename Value="../UMicroThreading.pas"/> 483 <Caret Line=" 309" Column="1" TopLine="285"/>481 <Caret Line="258" Column="1" TopLine="241"/> 484 482 </Position2> 485 483 <Position3> 486 484 <Filename Value="../UMicroThreading.pas"/> 487 <Caret Line=" 310" Column="1" TopLine="286"/>485 <Caret Line="261" Column="1" TopLine="241"/> 488 486 </Position3> 489 487 <Position4> 490 488 <Filename Value="../UMicroThreading.pas"/> 491 <Caret Line="3 12" Column="1" TopLine="288"/>489 <Caret Line="321" Column="13" TopLine="311"/> 492 490 </Position4> 493 491 <Position5> 494 492 <Filename Value="../UMicroThreading.pas"/> 495 <Caret Line=" 315" Column="1" TopLine="291"/>493 <Caret Line="116" Column="1" TopLine="103"/> 496 494 </Position5> 497 495 <Position6> 498 496 <Filename Value="../UMicroThreading.pas"/> 499 <Caret Line="3 38" Column="1" TopLine="323"/>497 <Caret Line="326" Column="1" TopLine="307"/> 500 498 </Position6> 501 499 <Position7> 502 500 <Filename Value="../UMicroThreading.pas"/> 503 <Caret Line=" 218" Column="1" TopLine="203"/>501 <Caret Line="183" Column="3" TopLine="159"/> 504 502 </Position7> 505 503 <Position8> 506 504 <Filename Value="../UMicroThreading.pas"/> 507 <Caret Line="2 19" Column="1" TopLine="203"/>505 <Caret Line="281" Column="40" TopLine="266"/> 508 506 </Position8> 509 507 <Position9> 510 508 <Filename Value="../UMicroThreading.pas"/> 511 <Caret Line=" 360" Column="1" TopLine="345"/>509 <Caret Line="183" Column="1" TopLine="172"/> 512 510 </Position9> 513 511 <Position10> 514 512 <Filename Value="../UMicroThreading.pas"/> 515 <Caret Line=" 290" Column="25" TopLine="275"/>513 <Caret Line="683" Column="3" TopLine="660"/> 516 514 </Position10> 517 515 <Position11> 518 516 <Filename Value="../UMicroThreading.pas"/> 519 <Caret Line="2 91" Column="28" TopLine="276"/>517 <Caret Line="273" Column="21" TopLine="260"/> 520 518 </Position11> 521 519 <Position12> 522 520 <Filename Value="../UMicroThreading.pas"/> 523 <Caret Line="28 6" Column="1" TopLine="276"/>521 <Caret Line="281" Column="1" TopLine="269"/> 524 522 </Position12> 525 523 <Position13> 526 524 <Filename Value="../UMicroThreading.pas"/> 527 <Caret Line=" 301" Column="1" TopLine="277"/>525 <Caret Line="282" Column="40" TopLine="269"/> 528 526 </Position13> 529 527 <Position14> 530 528 <Filename Value="../UMicroThreading.pas"/> 531 <Caret Line="28 6" Column="1" TopLine="277"/>529 <Caret Line="281" Column="44" TopLine="269"/> 532 530 </Position14> 533 531 <Position15> 534 532 <Filename Value="../UMicroThreading.pas"/> 535 <Caret Line="28 7" Column="1" TopLine="277"/>533 <Caret Line="282" Column="1" TopLine="269"/> 536 534 </Position15> 537 535 <Position16> 538 536 <Filename Value="../UMicroThreading.pas"/> 539 <Caret Line="28 8" Column="1" TopLine="277"/>537 <Caret Line="281" Column="3" TopLine="269"/> 540 538 </Position16> 541 539 <Position17> 542 540 <Filename Value="../UMicroThreading.pas"/> 543 <Caret Line=" 301" Column="1" TopLine="277"/>541 <Caret Line="282" Column="17" TopLine="263"/> 544 542 </Position17> 545 543 <Position18> 546 544 <Filename Value="../UMicroThreading.pas"/> 547 <Caret Line=" 302" Column="1" TopLine="278"/>545 <Caret Line="402" Column="1" TopLine="389"/> 548 546 </Position18> 549 547 <Position19> 550 548 <Filename Value="../UMicroThreading.pas"/> 551 <Caret Line=" 303" Column="1" TopLine="279"/>549 <Caret Line="270" Column="48" TopLine="262"/> 552 550 </Position19> 553 551 <Position20> 554 552 <Filename Value="../UMicroThreading.pas"/> 555 <Caret Line=" 304" Column="1" TopLine="280"/>553 <Caret Line="285" Column="1" TopLine="263"/> 556 554 </Position20> 557 555 <Position21> 558 556 <Filename Value="../UMicroThreading.pas"/> 559 <Caret Line=" 305" Column="1" TopLine="281"/>557 <Caret Line="282" Column="19" TopLine="269"/> 560 558 </Position21> 561 559 <Position22> 562 560 <Filename Value="../UMicroThreading.pas"/> 563 <Caret Line=" 306" Column="1" TopLine="282"/>561 <Caret Line="54" Column="26" TopLine="45"/> 564 562 </Position22> 565 563 <Position23> 566 564 <Filename Value="../UMicroThreading.pas"/> 567 <Caret Line=" 308" Column="1" TopLine="284"/>565 <Caret Line="283" Column="1" TopLine="270"/> 568 566 </Position23> 569 567 <Position24> 570 568 <Filename Value="../UMicroThreading.pas"/> 571 <Caret Line="3 09" Column="1" TopLine="285"/>569 <Caret Line="394" Column="1" TopLine="381"/> 572 570 </Position24> 573 571 <Position25> 574 572 <Filename Value="../UMicroThreading.pas"/> 575 <Caret Line="3 10" Column="1" TopLine="286"/>573 <Caret Line="385" Column="1" TopLine="380"/> 576 574 </Position25> 577 575 <Position26> 578 576 <Filename Value="../UMicroThreading.pas"/> 579 <Caret Line="3 11" Column="1" TopLine="287"/>577 <Caret Line="386" Column="1" TopLine="380"/> 580 578 </Position26> 581 579 <Position27> 582 <Filename Value=" ../UMicroThreading.pas"/>583 <Caret Line=" 313" Column="1" TopLine="289"/>580 <Filename Value="UMainForm.pas"/> 581 <Caret Line="274" Column="1" TopLine="252"/> 584 582 </Position27> 585 583 <Position28> 586 584 <Filename Value="../UMicroThreading.pas"/> 587 <Caret Line=" 316" Column="1" TopLine="292"/>585 <Caret Line="287" Column="43" TopLine="269"/> 588 586 </Position28> 589 587 <Position29> 590 588 <Filename Value="../UMicroThreading.pas"/> 591 <Caret Line=" 339" Column="1" TopLine="324"/>589 <Caret Line="286" Column="1" TopLine="269"/> 592 590 </Position29> 593 591 <Position30> 594 592 <Filename Value="../UMicroThreading.pas"/> 595 <Caret Line=" 286" Column="1" TopLine="271"/>593 <Caret Line="181" Column="3" TopLine="160"/> 596 594 </Position30> 597 595 </JumpHistory> … … 631 629 </CompilerOptions> 632 630 <Debugging> 633 <BreakPoints Count="1">634 <Item1>635 <Source Value="../UMicroThreading.pas"/>636 <Line Value="285"/>637 </Item1>638 </BreakPoints>639 631 <Exceptions Count="3"> 640 632 <Item1> -
MicroThreading/Demo/UMainForm.lfm
r150 r151 1 1 object MainForm: TMainForm 2 Left = 2 323 Height = 5 574 Top = 1165 Width = 8632 Left = 224 3 Height = 533 4 Top = 98 5 Width = 775 6 6 Caption = 'MicroThreading demo' 7 ClientHeight = 5 578 ClientWidth = 8637 ClientHeight = 533 8 ClientWidth = 775 9 9 OnClose = FormClose 10 10 OnCreate = FormCreate … … 14 14 object PageControl1: TPageControl 15 15 Left = 8 16 Height = 5 4316 Height = 519 17 17 Top = 8 18 Width = 84919 ActivePage = TabSheet 218 Width = 761 19 ActivePage = TabSheet1 20 20 Anchors = [akTop, akLeft, akRight, akBottom] 21 TabIndex = 121 TabIndex = 0 22 22 TabOrder = 0 23 23 object TabSheet1: TTabSheet 24 24 Caption = 'Job control' 25 ClientHeight = 51626 ClientWidth = 84525 ClientHeight = 493 26 ClientWidth = 753 27 27 object ButtonAddWorkers: TButton 28 28 Left = 10 … … 37 37 Left = 10 38 38 Height = 25 39 Top = 3740 Width = 1 4039 Top = 74 40 Width = 104 41 41 Caption = 'Clear jobs' 42 42 OnClick = ButtonClearMicroThreadsClick … … 44 44 end 45 45 object Label4: TLabel 46 Left = 12 046 Left = 124 47 47 Height = 14 48 48 Top = 14 49 Width = 10450 Caption = ' Microthread count:'49 Width = 34 50 Caption = 'Count:' 51 51 ParentColor = False 52 52 end 53 53 object SpinEdit1: TSpinEdit 54 Left = 2 2454 Left = 204 55 55 Height = 21 56 56 Top = 11 … … 62 62 end 63 63 object Memo1: TMemo 64 Left = 3 8265 Height = 2 6764 Left = 316 65 Height = 244 66 66 Top = 14 67 67 Width = 294 … … 71 71 end 72 72 object Button1: TButton 73 Left = 1 474 Height = 25 75 Top = 9473 Left = 12 74 Height = 25 75 Top = 138 76 76 Width = 75 77 77 Caption = 'Clear memo' … … 79 79 TabOrder = 4 80 80 end 81 object Label12: TLabel 82 Left = 123 83 Height = 14 84 Top = 38 85 Width = 52 86 Caption = 'Iterations:' 87 ParentColor = False 88 end 89 object SpinEdit3: TSpinEdit 90 Left = 204 91 Height = 21 92 Top = 36 93 Width = 74 94 MaxValue = 1000000000 95 OnChange = SpinEdit3Change 96 TabOrder = 5 97 Value = 100000 98 end 81 99 end 82 100 object TabSheet2: TTabSheet 83 101 Caption = 'Scheduler state' 84 ClientHeight = 51685 ClientWidth = 845102 ClientHeight = 493 103 ClientWidth = 753 86 104 object ListView1: TListView 87 105 Left = 222 88 Height = 4 83106 Height = 460 89 107 Top = 24 90 Width = 569108 Width = 477 91 109 Anchors = [akTop, akLeft, akRight, akBottom] 92 110 Columns = < … … 130 148 Height = 14 131 149 Top = 7 132 Width = 85150 Width = 74 133 151 Caption = 'Microthread list' 134 152 ParentColor = False … … 140 158 Width = 205 141 159 Caption = 'State' 142 ClientHeight = 6 6160 ClientHeight = 63 143 161 ClientWidth = 201 144 162 TabOrder = 1 … … 147 165 Height = 14 148 166 Top = 4 149 Width = 1 35167 Width = 117 150 168 Caption = 'Logical processor count:' 151 169 ParentColor = False … … 163 181 Height = 14 164 182 Top = 20 165 Width = 78183 Width = 69 166 184 Caption = 'Thread count:' 167 185 ParentColor = False … … 171 189 Height = 14 172 190 Top = 36 173 Width = 107191 Width = 95 174 192 Caption = 'Micro thread count:' 175 193 ParentColor = False … … 198 216 Width = 206 199 217 Caption = 'Control' 200 ClientHeight = 1 11218 ClientHeight = 108 201 219 ClientWidth = 202 202 220 TabOrder = 2 … … 214 232 Height = 14 215 233 Top = 46 216 Width = 78234 Width = 69 217 235 Caption = 'Thread count:' 218 236 ParentColor = False … … 230 248 object TabSheet3: TTabSheet 231 249 Caption = 'Testing' 232 ClientHeight = 516233 ClientWidth = 845250 ClientHeight = 493 251 ClientWidth = 753 234 252 object ButtonShowThreadId: TButton 235 253 Left = 14 … … 271 289 Height = 14 272 290 Top = 135 273 Width = 81291 Width = 70 274 292 Caption = 'Precision time:' 275 293 ParentColor = False -
MicroThreading/Demo/UMainForm.pas
r150 r151 26 26 Label10: TLabel; 27 27 Label11: TLabel; 28 Label12: TLabel; 28 29 Label2: TLabel; 29 30 Label3: TLabel; … … 39 40 SpinEdit1: TSpinEdit; 40 41 SpinEdit2: TSpinEdit; 42 SpinEdit3: TSpinEdit; 41 43 TabSheet1: TTabSheet; 42 44 TabSheet2: TTabSheet; … … 57 59 procedure ListView1Data(Sender: TObject; Item: TListItem); 58 60 procedure SpinEdit2Change(Sender: TObject); 61 procedure SpinEdit3Change(Sender: TObject); 59 62 procedure TimerRedrawTimer(Sender: TObject); 60 63 procedure TimerSchedulerStartTimer(Sender: TObject); … … 62 65 procedure Worker(MicroThread: TMicroThread); 63 66 public 67 Iterations: Integer; 64 68 Scheduler: TMicroThreadScheduler; 65 69 end; … … 209 213 procedure TMainForm.FormShow(Sender: TObject); 210 214 begin 215 Iterations := SpinEdit3.Value; 211 216 end; 212 217 … … 236 241 end; 237 242 243 procedure TMainForm.SpinEdit3Change(Sender: TObject); 244 begin 245 Iterations := SpinEdit3.Value; 246 end; 247 238 248 procedure TMainForm.TimerRedrawTimer(Sender: TObject); 239 249 begin 240 ListView1.Items.Count := Scheduler.MicroThreadCount; 250 if ListView1.Items.Count <> Scheduler.MicroThreadCount then 251 ListView1.Items.Count := Scheduler.MicroThreadCount; 241 252 ListView1.Items[-1]; 242 253 ListView1.Refresh; … … 258 269 I: Integer; 259 270 Q: Integer; 260 const261 TotalSteps = 100;262 271 begin 263 272 with MicroThread do begin 264 273 //Memo1.Lines.Add('Worker ' + IntToStr(Id)); 265 for I := 0 to TotalSteps - 1 do begin274 for I := 0 to Iterations - 1 do begin 266 275 Q := 0; 267 while Q < 100 00do Inc(Q);276 while Q < 100 do Inc(Q); 268 277 //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 269 278 // FloatToStr(ExecutionTime)); 270 Completion := I / TotalSteps;279 Completion := I / Iterations; 271 280 //Sleep(1 * Id * OneMillisecond); 272 281 Yield;
Note:
See TracChangeset
for help on using the changeset viewer.