v0.1.6 rc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7574509..424ce51 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,3 +25,9 @@
# 0.1.5
Additional Performance Optimizations & Documentation Updates
+
+# 0.1.6
+
+Documentation Updates
+
+- Performance Tests
diff --git a/README.md b/README.md
index 06ed774..24c3aa7 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@
```yaml
dependencies:
- equatable: ^0.1.5
+ equatable: ^0.1.6
```
Next, we need to install it:
@@ -161,3 +161,28 @@
Person(this.name) : super([name]);
}
```
+
+## Performance
+
+You might be wondering what the performance impact will be if you use `Equatable`.
+
+[Performance Tests](https://github.com/felangel/equatable/raw/master/performance_tests) have been written to test how `Equatable` stacks up to manually overriding `==` and `hashCode` in terms of class instantiation as well as equality comparison.
+
+
+### Results (average over 10 runs)
+
+#### Equality Comparison A == A
+
+| Class | Runtime (microseconds) |
+| ------------------ | ---------------------- |
+| RAW | 0.143 |
+| Empty Equatable | 0.124 |
+| Hydrated Equatable | 0.126 |
+
+#### Instantiation A()
+
+| Class | Runtime (microseconds) |
+| ------------------ | ---------------------- |
+| RAW | 0.099 |
+| Empty Equatable | 0.121 |
+| Hydrated Equatable | 0.251 |
diff --git a/performance_tests/README.md b/performance_tests/README.md
new file mode 100644
index 0000000..3c10585
--- /dev/null
+++ b/performance_tests/README.md
@@ -0,0 +1,28 @@
+# Equatable Performance Tests
+
+Benchmarks to measure how using `Equatable` will impact performance.
+
+
+## Running the Performance Tests
+
+```sh
+dart main.dart
+```
+
+## Results (average over 10 runs)
+
+### Equality Comparison A == A
+
+| Class | Runtime (microseconds) |
+| ------------------ | ---------------------- |
+| RAW | 0.143 |
+| Empty Equatable | 0.124 |
+| Hydrated Equatable | 0.126 |
+
+### Instantiation A()
+
+| Class | Runtime (microseconds) |
+| ------------------ | ---------------------- |
+| RAW | 0.099 |
+| Empty Equatable | 0.251 |
+| Hydrated Equatable | 0.121 |
\ No newline at end of file
diff --git a/performance_tests/main.dart b/performance_tests/main.dart
new file mode 100644
index 0000000..1dbd241
--- /dev/null
+++ b/performance_tests/main.dart
@@ -0,0 +1,124 @@
+import 'package:equatable/equatable.dart';
+import 'package:benchmark_harness/benchmark_harness.dart';
+
+class EmptyEquatable extends Equatable {}
+
+class LoginEvent extends Equatable {
+ final String username;
+ final String password;
+
+ LoginEvent({this.username, this.password}) : super([username, password]);
+}
+
+class LoginEventRaw {
+ final String username;
+ final String password;
+
+ const LoginEventRaw({this.username, this.password});
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is LoginEventRaw &&
+ runtimeType == other.runtimeType &&
+ username == other.username &&
+ password == other.password;
+
+ @override
+ int get hashCode => username.hashCode ^ password.hashCode;
+}
+
+void main() {
+ print('----Comparison Report----');
+
+ print('RAW:');
+ TemplateBenchmarkComparisonRaw().report();
+
+ print('Equatable:');
+ TemplateBenchmarkComparison().report();
+
+ print('Empty Equatable:');
+ TemplateBenchmarkComparisonEmpty().report();
+
+ print('----Instantiation Report----');
+
+ print('RAW:');
+ TemplateBenchmarkInstantiationRaw().report();
+
+ print('Equatable:');
+ TemplateBenchmarkInstantiation().report();
+
+ print('Empty Equatable:');
+ TemplateBenchmarkInstantiationEmpty().report();
+}
+
+class TemplateBenchmarkComparisonRaw extends BenchmarkBase {
+ TemplateBenchmarkComparisonRaw() : super("Template");
+
+ LoginEventRaw eventA;
+ void run() {
+ eventA == eventA;
+ }
+
+ @override
+ void setup() {
+ eventA = LoginEventRaw(username: 'username', password: 'password');
+ super.setup();
+ }
+}
+
+class TemplateBenchmarkComparison extends BenchmarkBase {
+ TemplateBenchmarkComparison() : super("Template");
+
+ LoginEvent eventA;
+
+ void run() {
+ eventA == eventA;
+ }
+
+ @override
+ void setup() {
+ eventA = LoginEvent(username: 'username', password: 'password');
+ super.setup();
+ }
+}
+
+class TemplateBenchmarkComparisonEmpty extends BenchmarkBase {
+ TemplateBenchmarkComparisonEmpty() : super("Template");
+
+ EmptyEquatable e;
+
+ void run() {
+ e == e;
+ }
+
+ @override
+ void setup() {
+ e = EmptyEquatable();
+ super.setup();
+ }
+}
+
+class TemplateBenchmarkInstantiationRaw extends BenchmarkBase {
+ TemplateBenchmarkInstantiationRaw() : super("Template");
+
+ void run() {
+ LoginEventRaw(username: 'felix', password: 'password');
+ }
+}
+
+class TemplateBenchmarkInstantiation extends BenchmarkBase {
+ TemplateBenchmarkInstantiation() : super("Template");
+
+ void run() {
+ LoginEvent(username: 'felix', password: 'password');
+ }
+}
+
+class TemplateBenchmarkInstantiationEmpty extends BenchmarkBase {
+ TemplateBenchmarkInstantiationEmpty() : super("Template");
+
+ void run() {
+ EmptyEquatable();
+ }
+}
diff --git a/performance_tests/pubspec.yaml b/performance_tests/pubspec.yaml
new file mode 100644
index 0000000..0547638
--- /dev/null
+++ b/performance_tests/pubspec.yaml
@@ -0,0 +1,9 @@
+name: equatable_performance_tests
+
+environment:
+ sdk: ">=2.0.0-dev.28.0 <3.0.0"
+
+dependencies:
+ equatable:
+ path: ../
+ benchmark_harness: 1.0.5
diff --git a/pubspec.yaml b/pubspec.yaml
index d616cfb..d1554a7 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: equatable
description: An abstract class that helps to implement equality without needing to explicitly override == and hashCode.
-version: 0.1.5
+version: 0.1.6
author: felix.angelov <felangelov@gmail.com>
homepage: https://github.com/felangel/equatable