Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix completion benchmark examples and recover inspector extension #17124

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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