Permalink
Browse files

Merge branch 'master' into CL-231

  • Loading branch information...
2 parents 9b005db + 262130f commit cc74e6680b550c746282276721e5d2fd2ab5cedd geremy cohen committed Oct 29, 2012
Showing with 4,719 additions and 436 deletions.
  1. +3 −0 app-showcase/performance-meter/README.md
  2. +86 −0 app-showcase/performance-meter/animate.js
  3. +55 −0 app-showcase/performance-meter/index.html
  4. BIN app-showcase/performance-meter/performance-meter.png
  5. +90 −0 app-showcase/performance-meter/performance.css
  6. +128 −0 app-showcase/performance-meter/performance.js
  7. +1 −0 csharp/3.3.0.1/.gitignore
  8. +35 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/Properties/AssemblyInfo.cs
  9. +78 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/PubNub-Messaging.Tests.csproj
  10. +60 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenAClientIsPresented.cs
  11. +147 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenAMessageIsPublished.cs
  12. +46 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenDetailedHistoryIsRequested.cs
  13. +40 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenGetRequestHistoryMessage.cs
  14. +34 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenGetRequestServerTime.cs
  15. +51 −0 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenSubscribedToAChannel.cs
  16. +76 −0 csharp/3.3.0.1/PubNub-Messaging/DetailedHistory_Example.cs
  17. +84 −0 csharp/3.3.0.1/PubNub-Messaging/Here_Now_Example.cs
  18. +74 −0 csharp/3.3.0.1/PubNub-Messaging/PresenceUnsubscribe_Example.cs
  19. +157 −0 csharp/3.3.0.1/PubNub-Messaging/Presence_Example.cs
  20. +112 −0 csharp/3.3.0.1/PubNub-Messaging/PubNub-Messaging.csproj
  21. +13 −0 csharp/3.3.0.1/PubNub-Messaging/PubNub-Messaging.csproj.user
  22. +114 −0 csharp/3.3.0.1/PubNub-Messaging/Publish_Example.cs
  23. +2,653 −0 csharp/3.3.0.1/PubNub-Messaging/Pubnub.cs
  24. +170 −0 csharp/3.3.0.1/PubNub-Messaging/Pubnub_Example.cs
  25. +227 −0 csharp/3.3.0.1/PubNub-Messaging/Subscribe_Example.cs
  26. +18 −0 csharp/3.3.0.1/PubNub-Messaging/app.config
  27. +42 −0 csharp/3.3.0.1/PubNub.sln
  28. BIN csharp/3.3.0.1/PubNub.suo
  29. +9 −9 javascript-modern/README.md
  30. +100 −96 titanium/3.3/mobile/chat-example-app/Resources/pubnub.js
  31. +2 −80 titanium/3.3/mobile/detailed-history-example-app/Resources/pubnub.js
  32. +2 −80 titanium/3.3/mobile/here-now-example-app/Resources/pubnub.js
  33. +10 −91 titanium/3.3/mobile/presence-example-app/Resources/pubnub.js
  34. +2 −80 titanium/3.3/mobile/pubnub.js
@@ -0,0 +1,3 @@
+# PubNub Performance Meter
+
+[PubNub Performance Meter - Try the Meter LIVE!](http://pubnub-status.s3.amazonaws.com/performance-meter/index.html)
@@ -0,0 +1,86 @@
+(function(){
+/* =-=====================================================================-= */
+/* =-=====================================================================-= */
+/* =-========================== ANIMATE ==========================-= */
+/* =-=====================================================================-= */
+/* =-=====================================================================-= */
+
+/*
+ animate( PUBNUB.$('m'), [
+ { 'd' : 2, 'r' : 360, 'background' : 'orange' },
+ { 'd' : 2, 's' : 2, 'r' : 30, 'background' : 'green' }
+ ] );
+*/
+
+var tranfaobigi = {
+ 'r' : 'rotate',
+ 'rz' : 'rotateZ',
+ 'rx' : 'rotateX',
+ 'ry' : 'rotateY',
+ 'p' : 'perspective',
+ 's' : 'scale',
+ 'm' : 'matrix',
+ 'tx' : 'translateX',
+ 'ty' : 'translateY'
+}, tranfaobigi_unit = {
+ 'r' : 'deg',
+ 'rz' : 'deg',
+ 'rx' : 'deg',
+ 'ry' : 'deg',
+ 'tx' : 'px',
+ 'ty' : 'px'
+}
+, each = PUBNUB.each
+, attr = PUBNUB.attr
+, animate = window['animate'] = function( node, keyframes, callback ) {
+ var keyframe = keyframes.shift()
+ , duration = (keyframe && keyframe['d'] || 1) * 1010
+ , callback = callback || function(){};
+
+ if (keyframe) transform( node, keyframe );
+ else return callback();
+
+ // ready for next keyframe
+ setTimeout( function(){
+ animate( node, keyframes, callback )
+ }, duration );
+};
+
+function transform( node, keyframe ) {
+ var tranbuff = []
+ , trans = ''
+ , stylebuff = []
+ , style = ''
+ , duration = (keyframe['d'] || 1) + 's';
+
+ delete keyframe['d'];
+
+ // Transformation CSS3
+ each( keyframe, function( k, v ) {
+ var what = tranfaobigi[k]
+ , unit = tranfaobigi_unit[k] || '';
+
+ if (!what) return;
+ delete keyframe[k];
+ tranbuff.push( what + '(' + v + unit + ')' );
+ } );
+ trans = tranbuff.join(' ') || '';
+
+ stylebuff.push(
+ '-o-transition:all ' + duration,
+ '-moz-transition:all ' + duration,
+ '-webkit-transition:all ' + duration,
+ 'transition:all ' + duration,
+ '-o-transform:' + trans,
+ '-moz-transform:' + trans,
+ '-webkit-transform:' + trans,
+ 'transform:' + trans
+ );
+
+ // CSS2
+ each( keyframe, function( k, v ) { stylebuff.push( k + ':' + v ) } );
+ style = stylebuff.join(';') || '';
+ try { attr( node, 'style', style ) } catch(e) {}
+}
+
+})();
@@ -0,0 +1,55 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <title>PubNub Performance Meter</title>
+
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <meta name=viewport content="width=640, user-scalable=no">
+ <meta name=apple-mobile-web-app-capable content=yes>
+ <meta name=apple-mobile-web-app-status-bar-style content=black>
+
+ <link rel=apple-touch-icon href=icon.png>
+ <link rel=apple-touch-startup-image href=startup.png>
+
+ <link href=performance.css rel=stylesheet>
+ <link href='http://fonts.googleapis.com/css?family=Exo:100,800'
+ rel='stylesheet'>
+</head>
+<body>
+
+<div id=performance>
+ <div id=performance-meter></div>
+ <div id=performance-arrow></div>
+ <div id=performance-meter-bezel></div>
+ <div id=performance-meter-number>0</div>
+ <div id=performance-meter-rps>MPS</div>
+</div>
+<div id=performance-medians></div>
+
+<!-- PUBNUB MEDIAN MPS TEMPLATE -->
+<script id=median-template type=template>
+<div><table><tr>
+ <td>{1}ms</td><td>{5}</td>
+ <td>{10}</td><td>{20}</td><td>{25}</td>
+ <td>{30}</td><td>{40}</td><td>{45}</td>
+</tr><tr class=fastest>
+ <td class=strong>Fastest</td><td class=strong>5%</td>
+ <td class=strong>10%</td><td class=strong>20%</td><td class=strong>25%</td>
+ <td class=strong>30%</td><td class=strong>40%</td><td class=strong>45%</td>
+</tr><tr>
+ <td>{50}</td><td>{66}</td><td>{75}</td>
+ <td>{80}</td><td>{90}</td><td>{95}</td><td>{99}</td><td>{100}</td>
+</tr><tr class=slowest>
+ <td class=strong>50%</td><td class=strong>66%</td><td class=strong>75%</td>
+ <td class=strong>80%</td><td class=strong>90%</td><td class=strong>95%</td>
+ <td class=strong>99%</td><td class=strong>Slowest</td>
+</tr></table></div>
+</script>
+
+<div id=pubnub></div>
+<script src=http://cdn.pubnub.com/pubnub-3.3.js></script>
+<script src=animate.js></script>
+<script src=performance.js></script>
+</body>
+</html>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,90 @@
+body { background: #efebdc; }
+table { width: 100%; }
+body, div, img {
+ padding: 0;
+ margin: 0;
+ border; 0;
+}
+#performance {
+ position: relative;
+ width: 640px;
+ height: 640px;
+ overflow: hidden;
+}
+
+#performance-meter {
+ position: absolute;
+ top: -11px;
+ left: 0px;
+ width: 640px;
+ height: 640px;
+ background: transparent url(./performance-meter.png) no-repeat 0px 0px;
+}
+#performance-meter-bezel {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ width: 640px;
+ height: 640px;
+ background: transparent url(./performance-meter.png) no-repeat -1280px 0px;
+}
+
+#performance-arrow {
+ position: absolute;
+ top: 10px;
+ left: 0px;
+ width: 640px;
+ height: 900px;
+ background: transparent url(./performance-meter.png) no-repeat -640px 0px;
+}
+
+#performance-meter-number {
+ position: absolute;
+ top: 330px;
+ left: 0px;
+ width: 640px;
+
+ color: #474332;
+ text-shadow: 0px 1px 20px rgba(0,0,0,0.5);
+ text-align: center;
+ font-family: Exo;
+ font-size: 110px;
+ font-weight: 100;
+}
+#performance-meter-rps {
+ position: absolute;
+ top: 460px;
+ left: 0px;
+ width: 640px;
+
+ color: #615c49;
+ opacity: 0.8;
+ text-shadow: 0px 1px 2px #fff;
+ text-align: center;
+ font-family: Exo;
+ font-size: 45px;
+ font-weight: 800;
+}
+#performance-medians {
+ border-top: 1px solid rgba(0,0,0,0.1);
+ margin-top: 10px;
+ padding-top: 20px;
+ width: 640px;
+ color: #615c57;
+ text-shadow: 0px 1px 2px #fff;
+ text-align: center;
+ font-family: Exo;
+ font-size: 22px;
+ font-weight: 100;
+}
+.strong {
+ font-family: Exo;
+ font-weight: 800;
+}
+.fastest {
+ color: #4e9a06;
+}
+.slowest {
+ color: #ce5c00;
+ color: #4e9a06;
+}
@@ -0,0 +1,128 @@
+(function(){
+
+
+function now() {return+new Date}
+
+// ----------------------------------------------------------------------
+// PUBLISH A MESSAGE (SEND)
+// ----------------------------------------------------------------------
+var net = PUBNUB.init({ publish_key:'demo', subscribe_key:'demo' })
+, channel = 'performance-meter-' + now() + Math.random()
+, start = now()
+, mps_avg = 0
+, lat_avg = 0
+, median = [0]
+, sent = 0
+, publish = (function(){
+ var sendqueue = []
+ , sending = 0;
+
+ function deliver() {
+ if (sendqueue.length) net.publish(sendqueue.pop())
+ else sending = 0;
+ }
+
+ return function( message, callback ) {
+ if (!net) return;
+
+ start = now();
+
+ sendqueue.push({
+ channel : channel,
+ message : message || 1,
+ callback : function(info) {
+ info && info[0] || publish( message, callback );
+ deliver();
+ callback && callback(info);
+ }
+ });
+ if (!sending) { sending = 1; deliver(); }
+ };
+})();
+
+// ----------------------------------------------------------------------
+// SUBSCRIBE FOR MESSAGES (RECEIVE)
+// ----------------------------------------------------------------------
+net.subscribe({
+ channel : channel,
+ connect : publish,
+ reconnect : publish,
+ callback : function() {
+ var latency = (now() - start) || median[1]
+ , new_mps_avg = 1000 / latency;
+
+ lat_avg = (latency + lat_avg) / 2;
+ mps_avg = (new_mps_avg + mps_avg) / 2;
+ median.push(latency);
+
+ start = now();
+ publish();
+ }
+});
+publish();
+setInterval( function() { set_rps(mps_avg) }, 500 );
+
+// ----------------------------------------------------------------------
+// CALCULATE MEDIAN VALUES
+// ----------------------------------------------------------------------
+var median_template = PUBNUB.$('median-template').innerHTML
+, median_out = PUBNUB.$('performance-medians');
+
+function update_medians() {
+ var length = median.length - 1
+ , medlen = Math.floor(length/2);
+
+ function get_median(val) {
+ return median[medlen + Math.floor(length * val)];
+ }
+ function get_median_low(val) {
+ return median[Math.floor(medlen * val)||1];
+ }
+
+ median = median.sort(function(a,b){return a-b});
+ console.log(median);
+
+ median_out.innerHTML = PUBNUB.supplant( median_template, {
+ '1' : median[1],
+
+ '2' : get_median_low(0.02),
+ '5' : get_median_low(0.05),
+ '10' : get_median_low(0.1),
+ '20' : get_median_low(0.2),
+ '25' : get_median_low(0.5),
+ '30' : get_median_low(0.6),
+ '40' : get_median_low(0.8),
+ '45' : get_median_low(0.9),
+
+ '50' : median[medlen],
+
+ '66' : get_median(0.16),
+ '75' : get_median(0.25),
+ '80' : get_median(0.30),
+ '90' : get_median(0.40),
+ '95' : get_median(0.45),
+ '98' : get_median(0.48),
+ '99' : get_median(0.49),
+
+ '100' : median[length-1]
+ } );
+}
+update_medians();
+
+// ----------------------------------------------------------------------
+// SET RPS FOR DISPLAY
+// ----------------------------------------------------------------------
+var set_rps = (function() {
+ var rps = PUBNUB.$('performance-meter-number')
+ , arrow = PUBNUB.$("performance-arrow");
+
+ return function (val) {
+ val = val || 0;
+ var meter = -90.0 + (val*6);
+ animate( arrow, [ { d : 0.5, r : meter > 90 ? 90 : meter } ] );
+ rps.innerHTML = ''+Math.ceil(val);
+ update_medians();
+ };
+})();
+
+})();
@@ -0,0 +1 @@
+/TestResults
Oops, something went wrong.

0 comments on commit cc74e66

Please sign in to comment.