als-document 0.12.0 → 1.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tests/cache.js ADDED
@@ -0,0 +1,19 @@
1
+ function mesureTime(fn) {
2
+ let time = performance.now()
3
+ const result = fn()
4
+ time = performance.now() - time
5
+ return {result,time}
6
+ }
7
+
8
+ describe('Cache and build from cache', () => {
9
+ const {result:root,time:rootTime} = mesureTime(() => parseHTML(html1))
10
+ const {result:cache,time:cacheTime} = mesureTime(() => cacheDoc(root))
11
+ const {result:root1,time:root1Time} = mesureTime(() => buildFromCache(cache))
12
+
13
+ it('HTML from cache and HTML from not cached same',() => {
14
+ console.log({rootTime,cacheTime,root1Time})
15
+ assert(cacheTime < 5,'Build cache takes less then 5ms')
16
+ assert(root1Time < 5,'Build DOM from cache takes less then 5ms')
17
+ assert(root.innerHTML === root1.innerHTML)
18
+ })
19
+ })