Skip to content

Commit

Permalink
Reduce example benchmark run count
Browse files Browse the repository at this point in the history
100 is excessive, and especially when testing web, it
can be frustrating. If CORS prevents loading WASM, it is
about 500 ms for L6 V2 and 1000 ms for L6 V3, each. It is
unreasonable to wait 1m40s for a benchmark.
  • Loading branch information
jpohhhh committed Dec 15, 2023
1 parent 1936595 commit 7e960d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions example/lib/minilml6v2_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class _MiniLmL6V2WidgetState extends State<MiniLmL6V2Widget> {
debugPrint('Loaded model');
// Warm up. This is not necessary, but it's nice to do. Only the first call
// to a model is slow.
for (var i = 0; i < 10; i++) {
for (var i = 0; i < 5; i++) {
await model.getEmbeddingAsVector(
textAndTokens[i % textAndTokens.length].tokens,
);
Expand All @@ -109,7 +109,7 @@ class _MiniLmL6V2WidgetState extends State<MiniLmL6V2Widget> {

final stopwatch = Stopwatch()..start();
var completed = 0;
while (completed < 100) {
while (completed < 20) {
await model.getEmbeddingAsVector(
textAndTokens[completed % textAndTokens.length].tokens);
completed++;
Expand Down
6 changes: 3 additions & 3 deletions example/lib/msmarco_minilm_l6v3_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class _MsmarcoMiniLmL6V3WidgetState extends State<MsmarcoMiniLmL6V3Widget> {
debugPrint('Loaded model');
// Warm up. This is not necessary, but it's nice to do. Only the first call
// to a model is slow.
for (var i = 0; i < 10; i++) {
for (var i = 0; i < 5; i++) {
await model.getEmbeddingAsVector(
textAndTokens[i % textAndTokens.length].tokens,
);
Expand All @@ -111,7 +111,7 @@ class _MsmarcoMiniLmL6V3WidgetState extends State<MsmarcoMiniLmL6V3Widget> {

final stopwatch = Stopwatch()..start();
var completed = 0;
while (completed < 100) {
while (completed < 20) {
await model.getEmbeddingAsVector(
textAndTokens[completed % textAndTokens.length].tokens);
completed++;
Expand All @@ -120,7 +120,7 @@ class _MsmarcoMiniLmL6V3WidgetState extends State<MsmarcoMiniLmL6V3Widget> {
final elapsed = stopwatch.elapsedMilliseconds;
final speed = (elapsed / completed.toDouble()).round();
setState(() {
_speedTestResult = '$speed ms for 400 words';
_speedTestResult = '$speed ms for 200 words';
});
}
}
Expand Down

0 comments on commit 7e960d9

Please sign in to comment.