Skip to content

Automatic (and invisible) performance measurements in JavaScript using aspect-oriented-programming.

Notifications You must be signed in to change notification settings

KDawg/AutoPerfMonJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

PerfMon R&D

This demo is based on a the technique Aspect Oriented Programming discussed by Rodrigo Fernandez. I saw his talk Monitoring for the Masses at HTML5DevConf

You'll see this demo uses AOP for automatically, and I'll claim invisibly, measuring code execution time. The browser's recently added User Timings API is leveraged because it is a highly precise timer producing results as fine as a fraction of a millisecond.

Running

Open the index.html and use the Chrome Developer Tools and look at the Console seeing program results. Read the JavaScript code confirming why the run-time output is interesting.

main.js has the main entry point of the source code. It has a series of local functions clearly documenting the process of setting up AOP, executing some slow code, reporting on the timing measurements, and breaking down the applied AOP. It uses two distinct styles of code.

RequireJS is used to bring in the meld library because it's built with that dependency module format. To keep consistency the project's rother sample code sits in files with modular definition.

server.js has the first style of code. It's a legit JavaScript Class. One of its functions is math intensive. That's what main applies AOP to for invisibly measuring execution time.

compute.js has a JavaScript object with some data and functional attributes. One of them is math intensive and that's what main applies AOP to. During the run you'll see it measure execution and report on it.

Measurement stats are recorded by the main app. It attaches its own functions that are run before and after the time consuming function implemented by the two modules it requires in.

Additional Reading

Read about AOP and learn why it's a useful technique.

Leverages a library called meld that implements AOP for J/S.

Some of this work takes advantage of the browser's User Timing API for high-resolution timers. APIs include:

performance.mark(), .measure(), .getEntriesByType()

Apparently the Java community established AOP pattern.

About

Automatic (and invisible) performance measurements in JavaScript using aspect-oriented-programming.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published