https://github.com/a145789/object-defineproperty-vs-proxy
Object.defineProperty vs Proxy
https://github.com/a145789/object-defineproperty-vs-proxy
proxy vue3
Last synced: 10 months ago
JSON representation
Object.defineProperty vs Proxy
- Host: GitHub
- URL: https://github.com/a145789/object-defineproperty-vs-proxy
- Owner: a145789
- Created: 2024-01-15T07:39:31.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T09:01:17.000Z (almost 2 years ago)
- Last Synced: 2025-01-25T17:27:52.388Z (12 months ago)
- Topics: proxy, vue3
- Language: JavaScript
- Homepage: https://a145789.github.io/object-defineproperty-vs-proxy/
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Object.defineProperty vs Proxy
在线测试地址:[https://a145789.github.io/object-defineproperty-vs-proxy/](https://a145789.github.io/object-defineproperty-vs-proxy/)
# 创建响应式,`Proxy` 性能更好
| | 运行 100 次 | 运行 1000 次 | 运行 10000 次 | 运行 100000 次 |
| -------------- | ----------- | ------------ | ------------- | -------------- |
| Proxy | 0.10 ms | 0.30 ms | 0.50 ms | 5.00 ms |
| defineProperty | 0.30 ms | 1.20 ms | 12.00 ms | 145.50 ms |
# 对响应式对象的读写性能,`Object.defineProperty` 性能更好
| | 运行 100 次 | 运行 1000 次 | 运行 10000 次 | 运行 100000 次 |
| -------------- | ----------- | ------------ | ------------- | -------------- |
| Proxy | 0.10 ms | 0.80 ms | 4.40 ms | 28.40 ms |
| defineProperty | 0.00 ms | 0.40 ms | 1.80 ms | 18.0 ms |
# 深度监听,二者差不多
| | 运行 100 次 | 运行 1000 次 | 运行 10000 次 | 运行 100000 次 |
| -------------- | ----------- | ------------ | ------------- | -------------- |
| Proxy | 0.00 ms | 0.30 ms | 3.40 ms | 32.40 ms |
| defineProperty | 0.00 ms | 0.40 ms | 2.80 ms | 30.90 ms |
> 参考 [https://github.com/y-temp4/object-defineproperty-vs-proxy.git/](https://github.com/y-temp4/object-defineproperty-vs-proxy.git/)