Skip to content

Commit

Permalink
Performance (#74)
Browse files Browse the repository at this point in the history
* Performance
* Add task to launch performance metrics on all combinations of use cases
* Add sui-perf dev dependency

* Remove unused arrow functions params as suggested @pablovegau

* Optional Performance Bootstraping
* Add window and performance instance as optional params in bootstrap
* Update performance use cases for use performance bootstrap from production code
* Add Container and Bootstrap performance in production code

* Fix integration tests

* Update minor version

* Add pull request template

* * Add Performance documentation
* Add Bootstraping marks in all use cases
  • Loading branch information
victuxbb authored Oct 9, 2018
1 parent 07d7498 commit 683a79c
Show file tree
Hide file tree
Showing 18 changed files with 346 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Background

X

# Goal

X

# Implementation

X

# Further considerations

X

# Checklist

- [ ] The PR relates to *only* one subject with a clear title.
- [ ] I have performed a self-review of my own code
- [ ] Wrote [good commit messages](http://chris.beams.io/posts/git-commit/)
- [ ] My code is readable by someone else, and I commented the hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works

3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ src
coverage
.travis.yml
.idea
.eslintignore
.eslintignore
resources
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ http://your.web.app/page?price=5000&openads_debug

Currently, OpenAds uses [LogLevel](https://github.com/pimterry/loglevel) as its logging framework.


# Performance

We care about performance, we know that showing ads in your page can penalize your user experience so we tried to do our best to not have bottle necks in our code.
You can take a look at the time line of all use cases using the performance task.

```bash
npm run performance
```

![Timeline performance](./resources/timeline.png)


# Roadmap

* Add support to Google AdSense
Expand Down
27 changes: 24 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "@schibstedspain/openads",
"version": "3.0.0",
"version": "3.1.0",
"description": "OpenAds: Advertising library",
"main": "dist/",
"scripts": {
"cleanDistFolder": "rm -Rf ./dist",
"prepublishOnly": "npm run cleanDistFolder && npm run build",
"build": "npm run cleanDistFolder && babel src --ignore test --out-dir dist ",
"test": "mocha --recursive --require babel-polyfill --compilers js:babel-register \"src/test/**/*.js\"",
"test:integration": "mocha --recursive --require babel-polyfill --compilers js:babel-register \"src/itest/**/*.js\"",
"test:integration": "mocha --recursive --require babel-polyfill --compilers js:babel-register \"src/itest/openads/**/*.js\"",
"coverage": "istanbul cover --report html _mocha -- ./src/*test --recursive --compilers js:babel-register",
"coverage:ci": "istanbul cover _mocha -- ./src/*test --recursive --compilers js:babel-register && codecov",
"performance": "babel-node src/itest/performance",
"watch": "onchange 'src/**/*.js' -- npm run build",
"lint": "sui-lint js"
},
Expand All @@ -23,10 +24,11 @@
"advertising",
"schibsted"
],
"author": "The Mighty Ducks of Advertising",
"author": "One Punch Team",
"license": "ISC",
"devDependencies": {
"@s-ui/lint": "^2.13.0",
"@s-ui/perf": "^1.4.0",
"@schibstedspain/openads-connector-api": "^1.2.0",
"babel-cli": "^6.24.0",
"babel-loader": "^7.1.4",
Expand Down
Binary file added resources/timeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import OpenAds from './openads/infrastructure/bootstrap/index'
import OpenAds from './openads/infrastructure/bootstrap/Main'
export default OpenAds
4 changes: 2 additions & 2 deletions src/itest/openads/infrastructure/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ContainerTest from '../configuration/ContainerTest'
import OpenAds from '../../../../openads/application/OpenAds'

export default class BootstrapTest {
static init ({config, appNexusClient}) {
return new OpenAds({container: new ContainerTest({config, appNexusClient})})
static init ({config}) {
return new OpenAds({container: new ContainerTest({config})})
}
}
19 changes: 10 additions & 9 deletions src/itest/openads/infrastructure/configuration/ContainerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import HTMLDOMDriver from '../../../../openads/infrastructure/service/HTMLDOMDri
import {JSDOM} from 'jsdom'

export default class ContainerTest extends Container {
constructor ({config, appNexusClient}) {
super({config, eager: false})
this._appNexusClient = appNexusClient
super._buildEagerSingletonInstances()
constructor ({config, eager = true} = {}) {
super({
config,
eager: false,
currentWindow: new HTMLDOMDriver({
dom: new JSDOM('<!DOCTYPE html><div id="forlayo">Hello world</div>').window
})
})
if (eager) super._buildEagerSingletonInstances()
}

_buildDOMDriver () {
return new HTMLDOMDriver({dom: new JSDOM('<!DOCTYPE html><div id="forlayo">Hello world</div>').window.document})
}

_buildAppNexusClient () {
return this._appNexusClient
return this._currentWindow
}
}
15 changes: 15 additions & 0 deletions src/itest/performance/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
addPositionAndDisplay,
addPosition,
displayNonexistentPosition,
refreshNonexistentPosition,
addPositionAndDisplayAndRefresh

} from './performanceUseCases'

Promise.resolve()
.then(() => addPosition())
.then(() => displayNonexistentPosition())
.then(() => refreshNonexistentPosition())
.then(() => addPositionAndDisplay())
.then(() => addPositionAndDisplayAndRefresh())
Loading

0 comments on commit 683a79c

Please sign in to comment.