| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // Copyright 1996 John Maloney and Mario Wolczko | 2 // Copyright 1996 John Maloney and Mario Wolczko |
| 3 // | 3 // |
| 4 // This file is part of GNU Smalltalk. | 4 // This file is part of GNU Smalltalk. |
| 5 // | 5 // |
| 6 // GNU Smalltalk is free software; you can redistribute it and/or modify it | 6 // GNU Smalltalk is free software; you can redistribute it and/or modify it |
| 7 // under the terms of the GNU General Public License as published by the Free | 7 // under the terms of the GNU General Public License as published by the Free |
| 8 // Software Foundation; either version 2, or (at your option) any later version. | 8 // Software Foundation; either version 2, or (at your option) any later version. |
| 9 // | 9 // |
| 10 // GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT | 10 // GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 623 |
| 624 /** | 624 /** |
| 625 * This is the standard DeltaBlue benchmark. A long chain of equality | 625 * This is the standard DeltaBlue benchmark. A long chain of equality |
| 626 * constraints is constructed with a stay constraint on one end. An | 626 * constraints is constructed with a stay constraint on one end. An |
| 627 * edit constraint is then added to the opposite end and the time is | 627 * edit constraint is then added to the opposite end and the time is |
| 628 * measured for adding and removing this constraint, and extracting | 628 * measured for adding and removing this constraint, and extracting |
| 629 * and executing a constraint satisfaction plan. There are two cases. | 629 * and executing a constraint satisfaction plan. There are two cases. |
| 630 * In case 1, the added constraint is stronger than the stay | 630 * In case 1, the added constraint is stronger than the stay |
| 631 * constraint and values must propagate down the entire length of the | 631 * constraint and values must propagate down the entire length of the |
| 632 * chain. In case 2, the added constraint is weaker than the stay | 632 * chain. In case 2, the added constraint is weaker than the stay |
| 633 * constraint so it cannot be accomodated. The cost in this case is, | 633 * constraint so it cannot be accommodated. The cost in this case is, |
| 634 * of course, very low. Typical situations lie somewhere between these | 634 * of course, very low. Typical situations lie somewhere between these |
| 635 * two extremes. | 635 * two extremes. |
| 636 */ | 636 */ |
| 637 void chainTest(int n) { | 637 void chainTest(int n) { |
| 638 planner = new Planner(); | 638 planner = new Planner(); |
| 639 Variable prev = null, first = null, last = null; | 639 Variable prev = null, first = null, last = null; |
| 640 // Build chain of n equality constraints. | 640 // Build chain of n equality constraints. |
| 641 for (int i = 0; i <= n; i++) { | 641 for (int i = 0; i <= n; i++) { |
| 642 Variable v = new Variable("v$i", 0); | 642 Variable v = new Variable("v$i", 0); |
| 643 if (prev != null) new EqualityConstraint(prev, v, REQUIRED); | 643 if (prev != null) new EqualityConstraint(prev, v, REQUIRED); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 EditConstraint edit = new EditConstraint(v, PREFERRED); | 696 EditConstraint edit = new EditConstraint(v, PREFERRED); |
| 697 Plan plan = planner.extractPlanFromConstraints(<EditConstraint>[edit]); | 697 Plan plan = planner.extractPlanFromConstraints(<EditConstraint>[edit]); |
| 698 for (int i = 0; i < 10; i++) { | 698 for (int i = 0; i < 10; i++) { |
| 699 v.value = newValue; | 699 v.value = newValue; |
| 700 plan.execute(); | 700 plan.execute(); |
| 701 } | 701 } |
| 702 edit.destroyConstraint(); | 702 edit.destroyConstraint(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 Planner planner; | 705 Planner planner; |
| OLD | NEW |