Changeset 230441 in webkit
- Timestamp:
- Apr 9, 2018 9:27:52 AM (6 years ago)
- Location:
- trunk/Websites/perf.webkit.org
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Websites/perf.webkit.org/ChangeLog
r230322 r230441 1 2018-04-06 Dewei Zhu <dewei_zhu@apple.com> 2 3 Added 'CommitSet.diff' which will be shared between multiple independent incoming changes. 4 https://bugs.webkit.org/show_bug.cgi?id=184368 5 6 Reviewed by Ryosuke Niwa. 7 8 'CommitSet.diff' will be used in multiple independent incoming changes. 9 It would be easier to make this a separate change to parallelize the changes depends on this API. 10 11 * public/v3/models/commit-set.js: 12 (CommitSet.prototype.createNameWithoutCollision): Moved from 'AnalysisTaskPage' and make it more generic. 13 (CommitSet.prototype.diff): Describe differences between 2 commit sets including commit, root and patch differences. 14 * public/v3/pages/analysis-task-page.js: Move 'AnalysisTaskPage._createRetryNameForTestGroup' to CommitSet in a more generic form. 15 (AnalysisTaskPage.prototype._retryCurrentTestGroup): Use 'CommitSet.withoutRootPatchOrOwnedCommit' instead. 16 (AnalysisTaskPage.prototype._createRetryNameForTestGroup): Moved to CommitSet in a more generic form. 17 * unit-tests/commit-set-tests.js: Added unit tests for 'CommitSet.diff'. 18 1 19 2018-04-05 Dewei Zhu <dewei_zhu@apple.com> 2 20 -
trunk/Websites/perf.webkit.org/public/v3/models/commit-set.js
r227568 r230441 146 146 return false; 147 147 } 148 149 static createNameWithoutCollision(name, existingNameSet) 150 { 151 console.assert(existingNameSet instanceof Set); 152 if (!existingNameSet.has(name)) 153 return name; 154 const nameWithNumberMatch = name.match(/(.+?)\s*\(\s*(\d+)\s*\)\s*$/); 155 let number = 1; 156 if (nameWithNumberMatch) { 157 name = nameWithNumberMatch[1]; 158 number = parseInt(nameWithNumberMatch[2]); 159 } 160 161 let newName; 162 do { 163 number++; 164 newName = `${name} (${number})`; 165 } while (existingNameSet.has(newName)); 166 167 return newName; 168 } 169 170 static diff(firstCommitSet, secondCommitSet) 171 { 172 console.assert(!firstCommitSet.equals(secondCommitSet)); 173 const allRepositories = new Set([...firstCommitSet.repositories(), ...secondCommitSet.repositories()]); 174 const sortedRepositories = Repository.sortByNamePreferringOnesWithURL([...allRepositories]); 175 const nameParts = []; 176 const missingCommit = {label: () => 'none'}; 177 const missingPatch = {filename: () => 'none'}; 178 const makeNameGenerator = () => { 179 const existingNameSet = new Set; 180 return (name) => { 181 const newName = CommitSet.createNameWithoutCollision(name, existingNameSet); 182 existingNameSet.add(newName); 183 return newName; 184 } 185 }; 186 187 for (const repository of sortedRepositories) { 188 const firstCommit = firstCommitSet.commitForRepository(repository) || missingCommit; 189 const secondCommit = secondCommitSet.commitForRepository(repository) || missingCommit; 190 const firstPatch = firstCommitSet.patchForRepository(repository) || missingPatch; 191 const secondPatch = secondCommitSet.patchForRepository(repository) || missingPatch; 192 const nameGenerator = makeNameGenerator(); 193 194 if (firstCommit == secondCommit && firstPatch == secondPatch) 195 continue; 196 197 if (firstCommit != secondCommit && firstPatch == secondPatch) 198 nameParts.push(`${repository.name()}: ${secondCommit.diff(firstCommit).label}`); 199 200 // FIXME: It would be nice if we can abbreviate the name when it's too long. 201 const nameForFirstPatch = nameGenerator(firstPatch.filename()); 202 const nameForSecondPath = nameGenerator(secondPatch.filename()); 203 204 if (firstCommit == secondCommit && firstPatch != secondPatch) 205 nameParts.push(`${repository.name()}: ${nameForFirstPatch} - ${nameForSecondPath}`); 206 207 if (firstCommit != secondCommit && firstPatch != secondPatch) 208 nameParts.push(`${repository.name()}: ${firstCommit.label()} with ${nameForFirstPatch} - ${secondCommit.label()} with ${nameForSecondPath}`); 209 } 210 211 if (firstCommitSet.allRootFiles().length || secondCommitSet.allRootFiles().length) { 212 const firstRootFileSet = new Set(firstCommitSet.allRootFiles()); 213 const secondRootFileSet = new Set(secondCommitSet.allRootFiles()); 214 const uniqueInFirstCommitSet = firstCommitSet.allRootFiles().filter((rootFile) => !secondRootFileSet.has(rootFile)); 215 const uniqueInSecondCommitSet = secondCommitSet.allRootFiles().filter((rootFile) => !firstRootFileSet.has(rootFile)); 216 const nameGenerator = makeNameGenerator(); 217 const firstDescription = uniqueInFirstCommitSet.map((rootFile) => nameGenerator(rootFile.filename())).join(', '); 218 const secondDescription = uniqueInSecondCommitSet.map((rootFile) => nameGenerator(rootFile.filename())).join(', '); 219 nameParts.push(`Roots: ${firstDescription || 'none'} - ${secondDescription || 'none'}`); 220 } 221 222 return nameParts.join(' '); 223 } 148 224 } 149 225 -
trunk/Websites/perf.webkit.org/public/v3/pages/analysis-task-page.js
r230295 r230441 786 786 _retryCurrentTestGroup(testGroup, repetitionCount) 787 787 { 788 const newName = this._createRetryNameForTestGroup(testGroup.name()); 788 const existingNames = (this._testGroups || []).map((group) => group.name()); 789 const newName = CommitSet.createNameWithoutCollision(testGroup.name(), new Set(existingNames)); 789 790 const commitSetList = testGroup.requestedCommitSets(); 790 791 const platform = this._task.platform() || testGroup.platform(); … … 840 841 alert('Failed to create a new test group: ' + error); 841 842 }); 842 }843 844 _createRetryNameForTestGroup(name)845 {846 var nameWithNumberMatch = name.match(/(.+?)\s*\(\s*(\d+)\s*\)\s*$/);847 var number = 1;848 if (nameWithNumberMatch) {849 name = nameWithNumberMatch[1];850 number = parseInt(nameWithNumberMatch[2]);851 }852 853 var newName;854 do {855 number++;856 newName = `${name} (${number})`;857 } while (this._hasDuplicateTestGroupName(newName));858 859 return newName;860 843 } 861 844 -
trunk/Websites/perf.webkit.org/unit-tests/commit-set-tests.js
r227568 r230441 28 28 return UploadedFile.ensureSingleton(457, {'createdAt': new Date('2017-05-01T21:03:27Z'), 'filename': 'root.dat', 'extension': '.dat', 'author': 'some user', 29 29 size: 16452111, sha256: '03eed7a8494ab8794c44b7d4308e55448fc56f4d6c175809ba968f78f656dbbb'}); 30 } 31 32 function createSharedRoot() 33 { 34 return UploadedFile.ensureSingleton(458, {'createdAt': new Date('2017-05-01T22:03:27Z'), 'filename': 'root.dat', 'extension': '.dat', 'author': 'some user', 35 size: 16452111, sha256: '03eed7a8494ab8794c44b7d4308e55448fc56f4aac175809ba968f78f656dbbb'}); 30 36 } 31 37 … … 105 111 } 106 112 113 function anotherWebKitCommit() 114 { 115 return CommitLog.ensureSingleton(2018, { 116 repository: MockModels.webkit, 117 revision: 'webkit-commit-1', 118 ownsCommits: false, 119 time: 1456932773000 120 }); 121 } 122 123 function commitWithSVNRevision() 124 { 125 return CommitLog.ensureSingleton(2019, { 126 repository: MockModels.webkit, 127 revision: '12345', 128 ownsCommits: false, 129 time: 1456932773000 130 }); 131 } 132 133 function anotherCommitWithSVNRevision() 134 { 135 return CommitLog.ensureSingleton(2020, { 136 repository: MockModels.webkit, 137 revision: '45678', 138 ownsCommits: false, 139 time: 1456932773000 140 }); 141 } 142 143 function commitWithGitRevision() 144 { 145 return CommitLog.ensureSingleton(2021, { 146 repository: MockModels.webkitGit, 147 revision: '13a0590d34f26fda3953c42ff833132a1a6f6f5a', 148 ownsCommits: false, 149 time: 1456932773000 150 }); 151 } 152 153 function anotherCommitWithGitRevision() 154 { 155 return CommitLog.ensureSingleton(2022, { 156 repository: MockModels.webkitGit, 157 revision: '2f8dd3321d4f51c04f4e2019428ce9ffe97f1ef1', 158 ownsCommits: false, 159 time: 1456932773000 160 }); 161 } 162 107 163 describe('CommitSet', () => { 108 164 MockRemoteAPI.inject(); … … 154 210 revisionItems: [{ commit: webkitCommit(), requiresBuild: false }], 155 211 customRoots: [createAnotherRoot()] 212 }); 213 } 214 215 function commitSetWithTwoRoots() 216 { 217 return CommitSet.ensureSingleton(7, { 218 revisionItems: [{ commit: webkitCommit(), requiresBuild: false }], 219 customRoots: [createRoot(), createSharedRoot()] 220 }); 221 } 222 223 function commitSetWithAnotherWebKitCommit() 224 { 225 return CommitSet.ensureSingleton(8, { 226 revisionItems: [{ commit: anotherWebKitCommit(), requiresBuild: false }], 227 customRoots: [] 228 }); 229 } 230 231 function commitSetWithAnotherCommitPatchAndRoot() 232 { 233 return CommitSet.ensureSingleton(9, { 234 revisionItems: [{ commit: anotherWebKitCommit(), requiresBuild: true, patch: createPatch()}], 235 customRoots: [createRoot(), createSharedRoot()] 236 }); 237 } 238 239 function commitSetWithSVNCommit() 240 { 241 return CommitSet.ensureSingleton(10, { 242 revisionItems: [{ commit: commitWithSVNRevision(), requiresBuild: false }], 243 customRoots: [] 244 }); 245 } 246 247 function anotherCommitSetWithSVNCommit() 248 { 249 return CommitSet.ensureSingleton(11, { 250 revisionItems: [{ commit: anotherCommitWithSVNRevision(), requiresBuild: false }], 251 customRoots: [] 252 }); 253 } 254 255 function commitSetWithGitCommit() 256 { 257 return CommitSet.ensureSingleton(12, { 258 revisionItems: [{ commit: commitWithGitRevision(), requiresBuild: false }], 259 customRoots: [] 260 }); 261 } 262 263 function anotherCommitSetWithGitCommit() 264 { 265 return CommitSet.ensureSingleton(13, { 266 revisionItems: [{ commit: anotherCommitWithGitRevision(), requiresBuild: false }], 267 customRoots: [] 268 }); 269 } 270 271 function commitSetWithTwoCommits() 272 { 273 return CommitSet.ensureSingleton(14, { 274 revisionItems: [{ commit: commitWithGitRevision(), requiresBuild: false }, { commit: commitWithSVNRevision(), requiresBuild: false }], 275 customRoots: [] 276 }); 277 } 278 279 function anotherCommitSetWithTwoCommits() 280 { 281 return CommitSet.ensureSingleton(15, { 282 revisionItems: [{ commit: anotherCommitWithGitRevision(), requiresBuild: false }, { commit: anotherCommitWithSVNRevision(), requiresBuild: false }], 283 customRoots: [] 156 284 }); 157 285 } … … 199 327 assert(oneMeasurementCommitSet().equals(oneCommitSet())); 200 328 }); 201 }) 329 }); 330 331 describe('diff', () => { 332 it('should describe patch difference', () => { 333 assert.equal(CommitSet.diff(commitSetWithPatch(), commitSetWithAnotherPatch()), 'WebKit: patch.dat - patch.dat (2)'); 334 }); 335 336 it('should describe root difference', () => { 337 assert.equal(CommitSet.diff(commitSetWithRoot(), anotherCommitSetWithRoot()), 'Roots: root.dat - root.dat (2)'); 338 assert.equal(CommitSet.diff(commitSetWithRoot(), commitSetWithTwoRoots()), 'Roots: none - root.dat'); 339 assert.equal(CommitSet.diff(commitSetWithTwoRoots(), oneCommitSet()), 'Roots: root.dat, root.dat (2) - none'); 340 }); 341 342 it('should describe commit difference', () => { 343 assert.equal(CommitSet.diff(oneCommitSet(), commitSetWithAnotherWebKitCommit()), 'WebKit: webkit-commit-0 - webkit-commit-1'); 344 assert.equal(CommitSet.diff(commitSetWithSVNCommit(), anotherCommitSetWithSVNCommit()), 'WebKit: r12345-r45678'); 345 assert.equal(CommitSet.diff(commitSetWithGitCommit(), anotherCommitSetWithGitCommit()), 'WebKit-Git: 13a0590d..2f8dd332'); 346 assert.equal(CommitSet.diff(commitSetWithTwoCommits(), anotherCommitSetWithTwoCommits()), 'WebKit: r12345-r45678 WebKit-Git: 13a0590d..2f8dd332'); 347 }); 348 349 it('should describe commit root and patch difference', () => { 350 assert.equal(CommitSet.diff(oneCommitSet(), commitSetWithAnotherCommitPatchAndRoot()), 'WebKit: webkit-commit-0 with none - webkit-commit-1 with patch.dat Roots: none - root.dat, root.dat (2)'); 351 }); 352 }); 202 353 }); 203 354
Note: See TracChangeset
for help on using the changeset viewer.