Skip to content

Commit

Permalink
Merge pull request #17124 from guillep/completion-fix
Browse files Browse the repository at this point in the history
Fix completion benchmark examples and recover inspector extension
  • Loading branch information
Ducasse authored Sep 18, 2024
2 parents d512ef9 + 6633c80 commit d84197b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/HeuristicCompletion-Model/CoBenchmarkContext.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ CoBenchmarkContext >> completionClass [
^ callsite methodNode methodClass
]

{ #category : 'accessing' }
CoBenchmarkContext >> completionToken [

^ callsite selector
]

{ #category : 'accessing' }
CoBenchmarkContext >> doItContext [

Expand Down
48 changes: 47 additions & 1 deletion src/HeuristicCompletion-Model/CoStaticBenchmarks.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@ I have an inspector extension to show the results in a table.
Examples:
```
global := CoStaticBenchmarks new
scope: (CoBenchmarkPackage on: SpAbstractAdapter package);
builder: (CoGlobalSorterResultSetBuilder new
sorterClass: AlphabeticSorter;
yourself);
run.
""Get the total accuracy of finding the right result among the first three when typing 2 characters.""
(global accuracyForCompletionIndex: (1 to: 3) withPrefixSize: 2) asFloat.
```
```
staticHeuristics := CoStaticBenchmarks new
scope: (CoBenchmarkPackage on: SpAbstractAdapter package);
builder: CoASTHeuristicsResultSetBuilder new;
run.
""Get the total accuracy of finding the right result among the first three when typing 2 characters.""
(staticHeuristics accuracyForCompletionIndex: (1 to: 3) withPrefixSize: 2) asFloat.
```
"
Class {
#name : 'CoStaticBenchmarks',
Expand Down Expand Up @@ -117,7 +127,43 @@ CoStaticBenchmarks >> gradeForPrefixSize: prefixSize [
CoStaticBenchmarks >> initialize [

super initialize.
completionBenchs := Dictionary new
completionBenchs := Dictionary new.
builder := CoASTHeuristicsResultSetBuilder new
]

{ #category : 'as yet unclassified' }
CoStaticBenchmarks >> inspectionResults [

<inspectorPresentationOrder: 0 title: 'Results'>
| table |
table := SpTablePresenter new
items: self completionIndexes;
addColumn: (SpCompositeTableColumn new
title: 'Prefix';
addColumn:
(SpStringTableColumn evaluated: [ :completionIndexRange |
| label |
label := '% '.
label := label , (completionIndexRange size = 1
ifTrue: [
{ 'fail'. '1st'. '2nd'. '3rd' } at:
completionIndexRange first + 1 ]
ifFalse: [
completionIndexRange first asString
, '-'
, completionIndexRange last asString ]).
label ]);
yourself).
self prefixSizes do: [ :prefixSize |
table addColumn: (SpStringTableColumn
title: prefixSize asString
evaluated: [ :completionIndexRange |
| float |
float := self
accuracyForCompletionIndex: completionIndexRange
withPrefixSize: prefixSize.
float * 100 printShowingDecimalPlaces: 2 ]) ].
^ table
]

{ #category : 'inspector' }
Expand Down

0 comments on commit d84197b

Please sign in to comment.