memory-stats-js-rails 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3aff56c9bb90f0009f5ac82d23a86113087c3cff
4
+ data.tar.gz: 2c47bc510c0de6d151699f7fb513eba617cd6bc2
5
+ SHA512:
6
+ metadata.gz: cc1d8aac3b1d23285c9251eecfc51de29a991b46d7cb82c01ac1a6fcf5c1c26eaed3be2974a007deb35da11dd61751b36420dc0f9966c4635c1c6647536798f8
7
+ data.tar.gz: fbcaa97fbc7e0f0db5afde9ea1a5788c19f1ca9e8daeb949049db1ec368ad97c8857dd938939cd6841e7989e7eba7df7ce278bbb6a9155f35ce4b2aa5858684a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jurre Stender
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # MemoryStatsJsRails
2
+
3
+ Easiest way to get [paulirish's memory-stats.js](https://github.com/paulirish/memory-stats.js) memory stats and [mrdoobs stats.js](https://github.com/mrdoob/stats.js/)
4
+ running in an ember-app. Please refer to the [memory-stats.js repo](https://github.com/paulirish/memory-stats.js) or [stats.js repo](https://github.com/mrdoob/stats.js/) for further documentation.
5
+
6
+ ![image](http://i.imgur.com/eUCFcAH.gif)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'memory-stats-js-rails'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install memory-stats-js-rails
23
+
24
+ ## Usage
25
+
26
+ In `app/assets/javascripts/application.js`: `//= require memory-stats`
27
+
28
+ And then something like:
29
+
30
+ ```javascript
31
+ var stats = new MemoryStats();
32
+
33
+ stats.domElement.style.position = 'fixed';
34
+ stats.domElement.style.right = '0px';
35
+ stats.domElement.style.bottom = '0px';
36
+
37
+ document.body.appendChild( stats.domElement );
38
+
39
+ requestAnimationFrame(function rAFloop(){
40
+ stats.update();
41
+ requestAnimationFrame(rAFloop);
42
+ });
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/memory-stats-js-rails/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @author mrdoob / http://mrdoob.com/
3
+ * @author jetienne / http://jetienne.com/
4
+ * @author paulirish / http://paulirish.com/
5
+ */
6
+ var MemoryStats = function (){
7
+
8
+ var msMin = 100;
9
+ var msMax = 0;
10
+
11
+ var container = document.createElement( 'div' );
12
+ container.id = 'stats';
13
+ container.style.cssText = 'width:80px;opacity:0.9;cursor:pointer';
14
+
15
+ var msDiv = document.createElement( 'div' );
16
+ msDiv.id = 'ms';
17
+ msDiv.style.cssText = 'padding:0 0 3px 3px;text-align:left;background-color:#020;';
18
+ container.appendChild( msDiv );
19
+
20
+ var msText = document.createElement( 'div' );
21
+ msText.id = 'msText';
22
+ msText.style.cssText = 'color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px';
23
+ msText.innerHTML= 'Memory';
24
+ msDiv.appendChild( msText );
25
+
26
+ var msGraph = document.createElement( 'div' );
27
+ msGraph.id = 'msGraph';
28
+ msGraph.style.cssText = 'position:relative;width:74px;height:30px;background-color:#0f0';
29
+ msDiv.appendChild( msGraph );
30
+
31
+ while ( msGraph.children.length < 74 ) {
32
+
33
+ var bar = document.createElement( 'span' );
34
+ bar.style.cssText = 'width:1px;height:30px;float:left;background-color:#131';
35
+ msGraph.appendChild( bar );
36
+
37
+ }
38
+
39
+ var updateGraph = function ( dom, height, color ) {
40
+
41
+ var child = dom.appendChild( dom.firstChild );
42
+ child.style.height = height + 'px';
43
+ if( color ) child.style.backgroundColor = color;
44
+
45
+ }
46
+
47
+ // polyfill usedJSHeapSize
48
+ if (window.performance && !performance.memory){
49
+ performance.memory = { usedJSHeapSize : 0 };
50
+ }
51
+
52
+ // support of the API?
53
+ if( performance.memory.totalJSHeapSize === 0 ){
54
+ console.warn('totalJSHeapSize === 0... performance.memory is only available in Chrome .')
55
+ }
56
+
57
+ // TODO, add a sanity check to see if values are bucketed.
58
+ // If so, reminde user to adopt the --enable-precise-memory-info flag.
59
+ // open -a "/Applications/Google Chrome.app" --args --enable-precise-memory-info
60
+
61
+ var lastTime = Date.now();
62
+ var lastUsedHeap= performance.memory.usedJSHeapSize;
63
+ return {
64
+ domElement: container,
65
+
66
+ update: function () {
67
+
68
+ // refresh only 30time per second
69
+ if( Date.now() - lastTime < 1000/30 ) return;
70
+ lastTime = Date.now()
71
+
72
+ var delta = performance.memory.usedJSHeapSize - lastUsedHeap;
73
+ lastUsedHeap = performance.memory.usedJSHeapSize;
74
+ var color = delta < 0 ? '#830' : '#131';
75
+
76
+ var ms = performance.memory.usedJSHeapSize;
77
+ msMin = Math.min( msMin, ms );
78
+ msMax = Math.max( msMax, ms );
79
+ msText.textContent = "Mem: " + bytesToSize(ms, 2);
80
+
81
+ var normValue = ms / (30*1024*1024);
82
+ var height = Math.min( 30, 30 - normValue * 30 );
83
+ updateGraph( msGraph, height, color);
84
+
85
+ function bytesToSize( bytes, nFractDigit ){
86
+ var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
87
+ if (bytes == 0) return 'n/a';
88
+ nFractDigit = nFractDigit !== undefined ? nFractDigit : 0;
89
+ var precision = Math.pow(10, nFractDigit);
90
+ var i = Math.floor(Math.log(bytes) / Math.log(1024));
91
+ return Math.round(bytes*precision / Math.pow(1024, i))/precision + ' ' + sizes[i];
92
+ };
93
+ }
94
+
95
+ }
96
+
97
+ };
@@ -0,0 +1,2 @@
1
+ require 'memory-stats-js/version'
2
+ require 'memory-stats-js/rails'
@@ -0,0 +1,6 @@
1
+ module MemoryStatsJs
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module MemoryStatsJs
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/memory-stats-js/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "memory-stats-js-rails"
6
+ spec.version = MemoryStatsJs::VERSION
7
+ spec.authors = ["Paul Irish", "Jerome Etienne", "Jurre Stender"]
8
+ spec.email = ["jurrestender+github@gmail.com"]
9
+ spec.description = %q{minimal monitor for JS Heap Size via performance.memory}
10
+ spec.summary = %q{minimal monitor for JS Heap Size via performance.memory}
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.require_paths = ["lib", "app"]
16
+
17
+ spec.add_development_dependency "bundler", "~> 1.3"
18
+ spec.add_development_dependency "rails", "~> 3.1"
19
+ spec.add_development_dependency "rake"
20
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: memory-stats-js-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Irish
8
+ - Jerome Etienne
9
+ - Jurre Stender
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-02-07 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.3'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rails
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '3.1'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.1'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ description: minimal monitor for JS Heap Size via performance.memory
58
+ email:
59
+ - jurrestender+github@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - app/assets/javascripts/memory-stats.js
70
+ - lib/memory-stats-js-rails.rb
71
+ - lib/memory-stats-js/rails.rb
72
+ - lib/memory-stats-js/version.rb
73
+ - memory-stats-js-rails.gemspec
74
+ homepage: ''
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ - app
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.5
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: minimal monitor for JS Heap Size via performance.memory
99
+ test_files: []