Permalink
Browse files

made static version of perf

  • Loading branch information...
1 parent e00d37d commit f6d2dd3349e1f3d9e78bad025aa2e4ee8d8f2956 brucero committed Mar 19, 2011
Showing with 142 additions and 4 deletions.
  1. +19 −1 bin/simple_svr.js
  2. +10 −1 bin/tohtml.js
  3. +14 −0 chess/README
  4. +4 −1 engine/core/xhr.js
  5. +1 −1 perf/perf.js
  6. +60 −0 perf/static.html
  7. +20 −0 perf/static.shtml
  8. +14 −0 pvn/README
View
20 bin/simple_svr.js
@@ -25,12 +25,30 @@ var fb_app_info={id:0,secret:0};
function serverCallback(req, res) {
var parse = url.parse(req.url);
var pathname = parse.pathname;
+ if (pathname.length <= 1) {
+ pathname = html_root;
+ }
+ console.log('pathname ' + pathname);
var split = pathname.split('/');
Comm.sendFile(req, res, pathname);
};
console.log("starting server");
+
+var listenPort = 8081;
+var html_root = '/perf/static.html';
+
+for(var i=0;i<process.argv.length;i++) {
+ if (process.argv[i] === '-port' && i+1 < process.argv.length) {
+ i++;
+ var listenPort = process.argv[i];
+ } else if (process.argv[i] === '-html' && i+1 < process.argv.length) {
+ i++;
+ var html_root = process.argv[i];
+ }
+}
+
fs.readFile('app_secret', 'binary', function(err, data) {
if (err) {
console.log('no app_secret file found, so no fb app login')
@@ -44,4 +62,4 @@ fs.readFile('app_secret', 'binary', function(err, data) {
}
});
var svr = http.createServer(serverCallback);
-svr.listen(8081);
+svr.listen(listenPort);
View
11 bin/tohtml.js
@@ -56,6 +56,7 @@ if (process.argv.length < 3) {
var req = {headers: {} };
//req.headers['user-agent'] = user_agent;
var options = {echo_only: true, fb_app_info: fb_app_info};
+ var dirs = [];
child.exec('find . -name "*.shtml" -print', function(err, stdout, stderr) {
if (!err && stdout) {
@@ -67,15 +68,23 @@ if (process.argv.length < 3) {
var file = fs.readFileSync(shtml, 'binary');
var txt = Comm.expandSHTML(req, file, shtml, options);
txt = '<!--- this file was autogenerated from a .shtml file ---->\n' + txt;
- getFileNames(txt,fnames);
+ var dir = list[i].substr(0,list[i].lastIndexOf('/'));
+ var readme = dir + '/README';
+ getFileNames(txt + "\n'"+readme+"'",fnames);
fnames[html] = txt;
console.log('convert ' + list[i] + ' to ' + html);
+ dirs.push(dir);
}
}
var queue = [];
for(var i in fnames) {
Jobs.add(queue,writeFile,'test/' + i,fnames[i]);
}
+ for(var i in dirs) {
+ Jobs.add(queue,function (dir) {
+ child.exec('cp -r '+dir+'/images test/'+dir+'/images', function(err) {});
+ },dirs[i]);
+ }
Jobs.run(queue);
}
});
View
14 chess/README
@@ -0,0 +1,14 @@
+Overview
+--------
+Pirate Chess is a multiplayer game that uses facebook requests instead of a server.
+Once you make a move and challenge some of your friends, the state of the board is
+stored in the request and passed back and forth. It runs on both mobile and desktop.
+
+It uses the code in the engine/ directory for rendering and input (this code is a stripped
+down version of the same code from https://github.com/facebook/jsgamebench )
+
+Installation
+------------
+Place the chess/ and engine/ directories into any webserver that can host static HTML files.
+
+Then, create a new Facebook Application, and set the fb_app_id in index.html to your app_id.
View
5 engine/core/xhr.js
@@ -16,6 +16,9 @@ var Xhr = (function() {
var socket;
function init() {
+ if (typeof(stand_alone) != 'undefined') {
+ return;
+ }
var options = {transports: ['xhr-polling']};
switch (Browser.browser) {
case Browser.CHROME:
@@ -42,7 +45,7 @@ var Xhr = (function() {
}
function toServer(cmd) {
- if (typeof(stand_alone) != 'undefined' && stand_alone) {
+ if (typeof(stand_alone) != 'undefined') {
return;
}
var unique_id = client_user.unique_id;
View
2 perf/perf.js
@@ -371,7 +371,7 @@ var Perf = (function() {
}
function setup() {
- if (!Browser.mobile) {
+ if (!Browser.mobile &&typeof(stand_alone) == 'undefined') {
Xhr.toServer({cmd: 'perfquery', args: [['browser']]});
} else {
ClientCmd.perfresp(null);
View
60 perf/static.html
@@ -0,0 +1,60 @@
+<!--- this file was autogenerated from a .shtml file ---->
+<html>
+ <head>
+<script type="text/javascript">var fb_app_id=0;</script>
+<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"/>
+<meta name="apple-mobile-web-app-capable" content="yes" />
+<meta name="apple-touch-fullscreen" content="yes" />
+<meta name="apple-mobile-web-app-status-bar-style" content="black" />
+
+<link rel="stylesheet" type="text/css" href="/engine/css/style.css" />
+
+<script type="text/javascript" src="/engine/core/json2.min.js"></script>
+<script type="text/javascript" src="/engine/core/browser.js"> </script>
+<script type="text/javascript" src="/engine/core/tick.js"> </script>
+<script type="text/javascript" src="/engine/core/clientutils.js"> </script>
+<script type="text/javascript" src="/engine/core/utils.js"> </script>
+<script type="text/javascript" src="/engine/utils/math.js"> </script>
+<script type="text/javascript" src="/engine/utils/vec.js"> </script>
+<script type="text/javascript" src="/engine/utils/math_3d.js"> </script>
+<script type="text/javascript" src="/engine/shared/grid.js"> </script>
+<script type="text/javascript" src="/engine/shared/gridclient.js"> </script>
+<script type="text/javascript" src="/engine/core/gameframe.js"> </script>
+<script type="text/javascript" src="/engine/core/ui.js"> </script>
+<script type="text/javascript" src="/engine/core/gob.js"> </script>
+<script type="text/javascript" src="/engine/core/igob.js"> </script>
+<script type="text/javascript" src="/engine/core/world.js"> </script>
+<script type="text/javascript" src="/engine/core/world_3d.js"> </script>
+<script type="text/javascript" src="/engine/core/sprites.js"> </script>
+<script type="text/javascript" src="/engine/core/spriteload.js"> </script>
+<script type="text/javascript" src="/engine/core/render.js"> </script>
+<script type="text/javascript" src="/engine/core/dom_render.js"> </script>
+<script type="text/javascript" src="/engine/core/canvas_render.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_util.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_debug.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_sprite.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_texture.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_material.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_model.js"> </script>
+<script type="text/javascript" src="/engine/core/webgl_render.js"> </script>
+<script type="text/javascript" src="/engine/core/input.js"> </script>
+<script type="text/javascript" src="/engine/core/clientcmd.js"> </script>
+<script type="text/javascript" src="/engine/core/init.js"> </script>
+<script type="text/javascript" src="/engine/core/xhr.js"> </script>
+ <script type="text/javascript">var stand_alone=true;</script>
+ <script type="text/javascript" src="/perf/benchmark.js"> </script>
+ <script type="text/javascript" src="/perf/perftest.js"> </script>
+ <script type="text/javascript" src="/perf/fbmark.js"> </script>
+ <script type="text/javascript" src="/perf/perf.js"> </script>
+ </head>
+
+ <body id="gamebody"
+ style=""
+ onresize="Init.winresize()"
+ onload="Init.init()"
+ onorientationchange="Init.winresize();"
+ onunload="Init.quit()">
+ </body>
+
+</html>
+
View
20 perf/static.shtml
@@ -0,0 +1,20 @@
+<html>
+ <head>
+ #include 'app_id'
+ #include '/engine/include/core.include'
+ <script type="text/javascript">var stand_alone=true;</script>
+ <script type="text/javascript" src="/perf/benchmark.js"> </script>
+ <script type="text/javascript" src="/perf/perftest.js"> </script>
+ <script type="text/javascript" src="/perf/fbmark.js"> </script>
+ <script type="text/javascript" src="/perf/perf.js"> </script>
+ </head>
+
+ <body id="gamebody"
+ style=""
+ onresize="Init.winresize()"
+ onload="Init.init()"
+ onorientationchange="Init.winresize();"
+ onunload="Init.quit()">
+ </body>
+
+</html>
View
14 pvn/README
@@ -0,0 +1,14 @@
+Overview
+--------
+Pirates vs Ninjas is a physics based game where the pirates try to knock down the ninjas
+dojo by launching cannonball-pirates at them. The code style has some oddity to it because
+it was two projects grafted together. It runs on both mobile and desktop.
+
+It uses the code in the engine/ directory for rendering and input (this code is a stripped
+down version of the same code from https://github.com/facebook/jsgamebench )
+
+Installation
+------------
+Place the pvn/ and engine/ directories into any webserver that can host static HTML files.
+
+Then, create a new Facebook Application, and set the fb_app_id in index.html to your app_id.

0 comments on commit f6d2dd3

Please sign in to comment.