You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-61
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,9 @@ A Go package providing a unified interface for loading and running various scrip
9
9
10
10
## Overview
11
11
12
-
go-polyscript provides a consistent API across different scripting engines, allowing for easy interchangeability and minimizing lock-in to a specific scripting language. This is achieved through a low-overhead abstraction of "machines," "executables," and the final "result". The input/output and runtime features provided by the scripting engines are standardized, which simplifies combining or swapping scripting engines in your application.
12
+
go-polyscript provides a consistent API across different scripting engines, allowing for easy interchangeability and minimizing lock-in to a specific scripting language. This package provides low-overhead abstractions of "machines," "executables," and the final "result". The API for the input/output and runtime are all standardized, which simplifies combining or swapping scripting engines in your application.
13
13
14
-
Currently supported scripting engines ("machines"):
14
+
Currently supported scripting engines "machines":
15
15
16
16
-**Risor**: A simple scripting language specifically designed for embedding in Go applications
17
17
-**Starlark**: Google's configuration language (a Python dialect) used in Bazel and many other tools
@@ -21,11 +21,10 @@ Currently supported scripting engines ("machines"):
21
21
22
22
-**Unified API**: Common interfaces for all supported scripting languages
23
23
-**Flexible Engine Selection**: Easily switch between different script engines
24
-
-**Powerful Data Passing**: Multiple ways to provide input data to scripts
25
-
-**Comprehensive Logging**: Structured logging with `slog` support
26
-
-**Error Handling**: Robust error handling and reporting from script execution
24
+
-**Thread-safe Data Management**: Multiple ways to provide input data to scripts
27
25
-**Compilation and Evaluation Separation**: Compile once, run multiple times with different inputs
28
26
-**Data Preparation and Evaluation Separation**: Prepare data in one step/system, evaluate in another
27
+
-**Slog Logging**: Customizable structured logging with `slog`
29
28
30
29
## Installation
31
30
@@ -35,7 +34,7 @@ go get github.com/robbyt/go-polyscript@latest
35
34
36
35
## Quick Start
37
36
38
-
Here's a simple example of using go-polyscript with the Risor scripting engine:
37
+
Using go-polyscript with the Risor scripting engine:
@@ -128,45 +119,57 @@ However, when using `StaticProvider`, each evaluation will always use the same i
128
119
The `ContextProvider` retrieves dynamic data from the context and makes it available to scripts. This is useful for scenarios where input data changes at runtime:
// In scripts, dynamic data is accessed via input_data:
143
137
// userId := ctx["input_data"]["userId"] // 123
144
138
```
145
139
146
-
### CompositeProvider
140
+
### Combining Static and Dynamic Data
147
141
148
-
To combine static data with dynamic runtime data, you can use the `CompositeProvider`. This allows you to stack a `StaticProvider` with a `ContextProvider`, enabling both fixed and variable data to be available during evaluation:
142
+
go-polyscript makes it easy to combine static configuration data with dynamic request data. This is a common pattern where you want both fixed configuration values and per-request variable data to be available during evaluation:
By using the `CompositeProvider`, you can ensure that your scripts have access to both constant configuration values and per-evaluation runtime data, making your evaluations more flexible and powerful.
172
+
This pattern ensures that your scripts have access to both constant configuration values and per-evaluation runtime data, making your evaluations more flexible and powerful.
170
173
171
174
## Architecture
172
175
@@ -198,7 +201,7 @@ go-polyscript provides the `EvalDataPreparer` interface to separate data prepara
198
201
199
202
```go
200
203
// Create an evaluator (implements EvaluatorWithPrep interface)
Copy file name to clipboardExpand all lines: benchmarks/README.md
+37-17
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
-
## Benchmarking VMs, and general optimization
1
+
#Benchmark Documentation
2
2
3
-
This directory contains benchmarking tools and historical benchmark records to track performance
4
-
characteristics of go-polyscript. These benchmarks serve as both documentation of optimization
5
-
effectiveness and protection against performance regressions. The data collected here demonstrates
6
-
the impact of various performance optimizations implemented throughout the package.
3
+
This directory contains benchmarking tools and historical benchmark records for go-polyscript performance analysis. Benchmarks serve as documentation of optimization effectiveness and protection against performance regressions.
The benchmarks also show performance differences between `data.Provider` implementations:
35
+
The benchmarks show performance differences between `data.Provider` implementations:
37
36
38
-
-**StaticProvider**: Fastest overall - use when runtime data is not needed, and input data is static
39
-
-**ContextProvider**: Needed for request-specific data that varies per execution, data stored in local memory
40
-
-**CompositeProvider**: Meta-provider, enabling multiple `data.Provider` objects in a series
37
+
-**StaticProvider**: Fastest overall (~5-10% faster than other providers) - use when input data is static
38
+
-**ContextProvider**: Needed for request-specific data that varies per execution
39
+
-**CompositeProvider**: Small overhead but enables both static configuration and dynamic request data
41
40
42
-
### 4. VM Selection Trade-offs
41
+
### 4. Script Engine Performance Characteristics
43
42
44
-
Performance characteristics vary by VM implementation:
43
+
Performance characteristics vary significantly by implementation:
45
44
46
-
-**Risor**: Fast general-purpose scripting with broad Go compatibility
47
-
-**Starlark**: Excellent for configuration processing with Python-like syntax
48
-
-**Extism/WASM**: Best security isolation with pre-compiled modules
45
+
-**Risor**: Generally fastest for general-purpose scripting with good Go interoperability
46
+
-**Starlark**: Optimized for configuration processing with Python-like syntax
47
+
-**Extism/WASM**: Best for security isolation with pre-compiled modules
49
48
50
-
###Running Benchmarks
49
+
## Running Benchmarks
51
50
52
51
To benchmark go-polyscript performance in your environment:
53
52
@@ -56,11 +55,32 @@ To benchmark go-polyscript performance in your environment:
56
55
make bench
57
56
58
57
# Run specific benchmark pattern
59
-
./benchmark.sh BenchmarkEvaluationPatterns
58
+
./benchmarks/run.sh BenchmarkEvaluationPatterns
60
59
61
60
# Quick benchmark without reports
62
61
make bench-quick
63
62
64
63
# Benchmark with specific iterations
65
64
go test -bench=BenchmarkVMComparison -benchmem -benchtime=10x ./engine
66
65
```
66
+
67
+
## Historical Results
68
+
69
+
Benchmark results are stored in the `results/` directory with timestamps. This allows tracking performance changes over time and identifying performance regressions:
70
+
71
+
-`benchmark_YYYY-MM-DD_HH-MM-SS.json` - Raw benchmark data
0 commit comments