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

Feature boa::Result<T> #637

Merged
merged 1 commit into from
Aug 17, 2020
Merged

Feature boa::Result<T> #637

merged 1 commit into from
Aug 17, 2020

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Aug 16, 2020

Related to #445

This PRs removes the ResultValue and adds a generic type alias Result<T> where the Err is Value, this is common practice and is done in many places in the standard library, serde, etc (example std::fmt::Result, std::io::Result, serde::Result)

It changes the following:

  • Removed ResultValue.
  • Added type alias type Result<T> = StdResult<T, Value>

@HalidOdat HalidOdat added enhancement New feature or request API labels Aug 16, 2020
@HalidOdat HalidOdat added this to the v0.10.0 milestone Aug 16, 2020
@HalidOdat HalidOdat changed the title Added Result<T> Added boa::Result<T> Aug 16, 2020
@codecov
Copy link

codecov bot commented Aug 16, 2020

Codecov Report

Merging #637 into master will decrease coverage by 0.04%.
The diff coverage is 79.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #637      +/-   ##
==========================================
- Coverage   72.62%   72.58%   -0.05%     
==========================================
  Files         179      179              
  Lines       13279    13255      -24     
==========================================
- Hits         9644     9621      -23     
+ Misses       3635     3634       -1     
Impacted Files Coverage Δ
boa/src/builtins/boolean/mod.rs 36.66% <0.00%> (ø)
boa/src/builtins/error/mod.rs 32.00% <0.00%> (ø)
boa/src/builtins/error/syntax.rs 36.36% <0.00%> (ø)
boa/src/builtins/function/mod.rs 70.65% <0.00%> (-2.40%) ⬇️
boa/src/builtins/mod.rs 22.58% <ø> (ø)
boa/src/builtins/value/conversions.rs 52.30% <ø> (+3.03%) ⬆️
boa/src/builtins/console/mod.rs 29.37% <5.88%> (ø)
boa/src/builtins/object/mod.rs 38.11% <58.33%> (ø)
boa/src/builtins/string/mod.rs 45.81% <60.00%> (ø)
boa/src/builtins/value/operations.rs 44.40% <77.77%> (ø)
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e7b362...d415103. Read the comment docs.

@HalidOdat HalidOdat marked this pull request as ready for review August 16, 2020 15:34
@github-actions
Copy link

Benchmark for 242a2f5

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 367.0±12.53ns 374.9±11.50ns -2.11%
Arithmetic operations (Full) 230.2±11.93µs 252.6±9.52µs -8.87%
Array access (Execution) 7.9±0.41µs 7.3±0.45µs +8.22%
Array access (Full) 257.3±20.46µs 243.3±13.33µs +5.75%
Array creation (Execution) 3.3±0.19ms 3.1±0.18ms +6.45%
Array creation (Full) 3.7±0.11ms 3.6±0.14ms +2.78%
Array pop (Execution) 1155.9±61.62µs 1179.0±48.27µs -1.96%
Array pop (Full) 1595.9±62.33µs 1494.3±86.38µs +6.80%
Boolean Object Access (Execution) 4.2±0.12µs 4.1±0.16µs +2.44%
Boolean Object Access (Full) 235.8±10.66µs 254.8±24.07µs -7.46%
Create Realm 452.5±29.66ns 460.1±17.71ns -1.65%
Dynamic Object Property Access (Execution) 4.8±0.32µs 5.0±0.17µs -4.00%
Dynamic Object Property Access (Full) 254.0±7.95µs 248.2±7.03µs +2.34%
Expression (Lexer) 2.3±0.09µs 2.5±0.08µs -8.00%
Expression (Parser) 5.4±0.15µs 5.2±0.28µs +3.85%
Fibonacci (Execution) 843.6±35.07µs 818.5±47.21µs +3.07%
Fibonacci (Full) 1174.5±58.54µs 1162.5±31.30µs +1.03%
For loop (Execution) 20.2±1.12µs 20.0±1.03µs +1.00%
For loop (Full) 272.1±8.80µs 273.1±6.59µs -0.37%
For loop (Lexer) 5.4±0.20µs 5.5±0.18µs -1.82%
For loop (Parser) 14.1±0.41µs 13.8±0.47µs +2.17%
Goal Symbols (Parser) 8.6±0.32µs 8.3±0.27µs +3.61%
Hello World (Lexer) 801.9±30.19ns 834.8±35.08ns -3.94%
Hello World (Parser) 2.1±0.11µs 2.0±0.12µs +5.00%
Long file (Parser) 6.3±0.11ms 6.3±0.17ms 0.00%
Number Object Access (Execution) 3.3±0.14µs 3.2±0.10µs +3.12%
Number Object Access (Full) 231.3±10.97µs 249.5±11.80µs -7.29%
Object Creation (Execution) 4.0±0.17µs 4.0±0.17µs 0.00%
Object Creation (Full) 303.5±9.71µs 289.7±18.32µs +4.76%
RegExp (Execution) 62.7±2.86µs 63.8±2.56µs -1.72%
RegExp (Full) 402.5±19.23µs 391.4±12.20µs +2.84%
RegExp Literal (Execution) 64.6±3.53µs 69.0±2.61µs -6.38%
RegExp Literal (Full) 317.6±15.73µs 323.1±9.28µs -1.70%
RegExp Literal Creation (Execution) 63.9±3.11µs 64.4±3.02µs -0.78%
RegExp Literal Creation (Full) 404.0±12.93µs 389.9±13.67µs +3.62%
Static Object Property Access (Execution) 4.1±0.26µs 4.2±0.19µs -2.38%
Static Object Property Access (Full) 256.4±8.48µs 239.2±10.62µs +7.19%
String Object Access (Execution) 6.3±0.21µs 6.2±0.16µs +1.61%
String Object Access (Full) 238.0±11.84µs 252.3±14.88µs -5.67%
String comparison (Execution) 5.7±0.21µs 5.3±0.31µs +7.55%
String comparison (Full) 248.0±13.01µs 248.0±9.79µs 0.00%
String concatenation (Execution) 4.5±0.15µs 4.6±0.36µs -2.17%
String concatenation (Full) 246.4±9.36µs 253.6±19.80µs -2.84%
String copy (Execution) 3.4±0.12µs 3.4±0.13µs 0.00%
String copy (Full) 240.0±8.38µs 242.1±12.31µs -0.87%
Symbols (Execution) 2.7±0.18µs 2.7±0.13µs 0.00%
Symbols (Full) 230.7±7.21µs 220.8±9.14µs +4.48%

@HalidOdat HalidOdat changed the title Added boa::Result<T> Feature boa::Result<T> Aug 16, 2020
@HalidOdat
Copy link
Member Author

This is ready for review/merge :)

@github-actions
Copy link

Benchmark for 5a25784

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 302.9±14.85ns 303.8±25.35ns -0.30%
Arithmetic operations (Full) 215.0±11.76µs 226.1±10.48µs -4.91%
Array access (Execution) 7.3±0.38µs 7.3±0.43µs 0.00%
Array access (Full) 226.9±10.51µs 234.6±11.30µs -3.28%
Array creation (Execution) 2.8±0.12ms 2.9±0.14ms -3.45%
Array creation (Full) 3.1±0.16ms 3.0±0.12ms +3.33%
Array pop (Execution) 977.2±61.12µs 1009.2±48.01µs -3.17%
Array pop (Full) 1302.2±94.10µs 1296.7±78.64µs +0.42%
Boolean Object Access (Execution) 3.7±0.17µs 3.7±0.20µs 0.00%
Boolean Object Access (Full) 225.5±13.82µs 238.3±15.76µs -5.37%
Create Realm 404.9±24.89ns 396.3±26.82ns +2.17%
Dynamic Object Property Access (Execution) 4.6±0.23µs 4.6±0.24µs 0.00%
Dynamic Object Property Access (Full) 231.4±17.61µs 239.8±13.75µs -3.50%
Expression (Lexer) 2.2±0.12µs 2.1±0.13µs +4.76%
Expression (Parser) 4.4±0.32µs 4.7±0.26µs -6.38%
Fibonacci (Execution) 848.7±57.26µs 906.7±49.12µs -6.40%
Fibonacci (Full) 1087.0±62.65µs 1077.9±59.24µs +0.84%
For loop (Execution) 19.6±1.15µs 21.2±1.40µs -7.55%
For loop (Full) 246.9±13.08µs 247.5±19.22µs -0.24%
For loop (Lexer) 4.5±0.25µs 4.7±0.26µs -4.26%
For loop (Parser) 12.4±0.65µs 12.6±0.64µs -1.59%
Goal Symbols (Parser) 7.2±0.39µs 7.5±0.45µs -4.00%
Hello World (Lexer) 715.5±37.19ns 752.5±37.95ns -4.92%
Hello World (Parser) 1841.3±101.49ns 1898.9±147.42ns -3.03%
Long file (Parser) 5.6±0.23ms 5.8±0.27ms -3.45%
Number Object Access (Execution) 3.0±0.14µs 2.9±0.15µs +3.45%
Number Object Access (Full) 221.0±15.51µs 226.4±10.40µs -2.39%
Object Creation (Execution) 3.8±0.19µs 4.0±0.27µs -5.00%
Object Creation (Full) 272.6±18.60µs 269.5±22.26µs +1.15%
RegExp (Execution) 60.5±4.19µs 59.4±3.54µs +1.85%
RegExp (Full) 354.5±18.46µs 369.9±21.83µs -4.16%
RegExp Literal (Execution) 62.7±2.83µs 63.1±3.29µs -0.63%
RegExp Literal (Full) 302.8±26.40µs 306.7±17.42µs -1.27%
RegExp Literal Creation (Execution) 60.2±4.05µs 60.3±3.13µs -0.17%
RegExp Literal Creation (Full) 349.1±16.77µs 366.9±21.52µs -4.85%
Static Object Property Access (Execution) 4.2±0.25µs 4.1±0.30µs +2.44%
Static Object Property Access (Full) 221.5±10.13µs 234.0±12.53µs -5.34%
String Object Access (Execution) 5.6±0.29µs 5.7±0.37µs -1.75%
String Object Access (Full) 233.0±19.71µs 238.6±15.66µs -2.35%
String comparison (Execution) 5.4±0.33µs 5.3±0.29µs +1.89%
String comparison (Full) 230.5±13.72µs 241.1±16.92µs -4.40%
String concatenation (Execution) 4.3±0.25µs 4.2±0.24µs +2.38%
String concatenation (Full) 221.9±12.41µs 229.5±10.39µs -3.31%
String copy (Execution) 3.2±0.18µs 3.2±0.16µs 0.00%
String copy (Full) 215.8±14.35µs 234.2±22.86µs -7.86%
Symbols (Execution) 2.6±0.13µs 2.6±0.15µs 0.00%
Symbols (Full) 203.9±14.92µs 201.5±10.06µs +1.19%

Copy link

@Lan2u Lan2u left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

@Razican
Copy link
Member

Razican commented Aug 17, 2020

It just needs a rebase :)

@HalidOdat HalidOdat merged commit d025207 into master Aug 17, 2020
@HalidOdat HalidOdat deleted the feature/result branch August 17, 2020 09:46
@github-actions
Copy link

Benchmark for bf37468

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 370.7±9.47ns 359.2±14.14ns +3.20%
Arithmetic operations (Full) 240.9±14.64µs 229.8±8.88µs +4.83%
Array access (Execution) 7.9±0.31µs 7.6±0.33µs +3.95%
Array access (Full) 253.4±11.77µs 247.6±8.54µs +2.34%
Array creation (Execution) 3.2±0.11ms 3.2±0.10ms 0.00%
Array creation (Full) 3.6±0.17ms 3.8±0.35ms -5.26%
Array pop (Execution) 1138.8±72.29µs 1137.5±31.99µs +0.11%
Array pop (Full) 1593.1±49.49µs 1541.0±95.31µs +3.38%
Boolean Object Access (Execution) 3.9±0.09µs 4.0±0.11µs -2.50%
Boolean Object Access (Full) 245.0±16.11µs 246.9±6.80µs -0.77%
Create Realm 436.7±15.98ns 458.9±30.13ns -4.84%
Dynamic Object Property Access (Execution) 4.8±0.19µs 4.9±0.16µs -2.04%
Dynamic Object Property Access (Full) 267.7±15.66µs 249.4±6.51µs +7.34%
Expression (Lexer) 2.3±0.09µs 2.3±0.11µs 0.00%
Expression (Parser) 5.2±0.16µs 5.3±0.11µs -1.89%
Fibonacci (Execution) 866.2±19.40µs 837.6±37.75µs +3.41%
Fibonacci (Full) 1118.7±44.04µs 1153.9±59.77µs -3.05%
For loop (Execution) 21.3±0.82µs 21.6±0.68µs -1.39%
For loop (Full) 266.2±17.57µs 264.0±10.06µs +0.83%
For loop (Lexer) 5.1±0.26µs 5.0±0.17µs +2.00%
For loop (Parser) 13.6±0.61µs 14.1±0.71µs -3.55%
Goal Symbols (Parser) 8.3±0.17µs 8.5±0.40µs -2.35%
Hello World (Lexer) 778.4±24.57ns 782.9±31.14ns -0.57%
Hello World (Parser) 2.0±0.06µs 2.1±0.10µs -4.76%
Long file (Parser) 6.0±0.12ms 6.3±0.17ms -4.76%
Number Object Access (Execution) 3.2±0.07µs 3.2±0.08µs 0.00%
Number Object Access (Full) 235.2±8.53µs 256.0±23.14µs -8.12%
Object Creation (Execution) 4.0±0.15µs 4.0±0.20µs 0.00%
Object Creation (Full) 297.3±26.72µs 292.2±12.71µs +1.75%
RegExp (Execution) 66.3±3.97µs 64.6±4.08µs +2.63%
RegExp (Full) 382.0±23.60µs 392.7±15.63µs -2.72%
RegExp Literal (Execution) 67.9±3.15µs 65.7±2.31µs +3.35%
RegExp Literal (Full) 322.1±19.26µs 321.8±12.86µs +0.09%
RegExp Literal Creation (Execution) 65.4±3.89µs 62.0±2.11µs +5.48%
RegExp Literal Creation (Full) 381.8±12.01µs 413.1±15.67µs -7.58%
Static Object Property Access (Execution) 4.2±0.18µs 4.1±0.18µs +2.44%
Static Object Property Access (Full) 248.2±12.44µs 241.7±10.05µs +2.69%
String Object Access (Execution) 6.4±0.30µs 6.1±0.20µs +4.92%
String Object Access (Full) 243.9±12.09µs 250.2±13.70µs -2.52%
String comparison (Execution) 5.8±0.21µs 5.7±0.22µs +1.75%
String comparison (Full) 251.3±32.54µs 246.9±10.42µs +1.78%
String concatenation (Execution) 4.6±0.19µs 4.6±0.17µs 0.00%
String concatenation (Full) 247.0±30.02µs 244.5±13.28µs +1.02%
String copy (Execution) 3.6±0.15µs 3.4±0.10µs +5.88%
String copy (Full) 234.2±9.86µs 248.3±18.17µs -5.68%
Symbols (Execution) 2.8±0.26µs 3.0±0.20µs -6.67%
Symbols (Full) 226.9±7.15µs 224.1±11.87µs +1.25%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants