Skip to content

Split the executing of javascript code, make the browser ui thread free

Notifications You must be signed in to change notification settings

valaxy/slice-perform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dependency Status

Split executing of javascript code into slice

Normal Javascript

import slicePerform, {_clock} from '../lib/index'
const COUNT = 10000000


let begin = _clock()
for (var index = 0; index < COUNT; index++);
let duration = _clock() - begin

console.log(index, `${duration / 1000000000}s`)

Slice Javascript

const slicePerform = require('slice-perform')
const COUNT = 10000000

let index = 0
slicePerform(
	90, // sliceTimeInMS
	10, // waitTimeInMS, in wait time, ui thread will not be blocked by javascript
	() => index < COUNT,  // test
	() => index += 1,     // fn
	(duration) => console.log(index, `${duration / 1000000000}s`) // callback
)

About

Split the executing of javascript code, make the browser ui thread free

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published