Permalink
Browse files

Added c compiler code

  • Loading branch information...
davglass committed Apr 4, 2011
1 parent 07d5b8b commit d1c8c8f35992ab5b2ca4e0d14f6c78eae47c338a
View
@@ -0,0 +1,15 @@
+all: files source
+
+source:
+ node-waf configure build
+
+files: clean
+ ./scripts/fetch_source.js
+ make sync
+
+sync:
+ cat ../lib/* >> ./src/lib/nodejs_yui3.js
+ cp ./src/yui.js ./src/lib/
+
+clean:
+ ./scripts/clean.sh
View
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+if [ -d ./build ]; then
+ rm -r ./build
+fi
+
+if [ -d ./src ]; then
+ rm -r ./src
+ mkdir ./src
+fi
+
+if [ -d .lock-wscript ]; then
+ rm -r .lock-wscript
+fi
+
@@ -0,0 +1,81 @@
+#!/usr/bin/env node
+
+var yui3 = require('yui3'),
+ fs = require('fs'),
+ path = require('path'),
+ cli = require('cli'),
+ start = (new Date()).getTime();
+
+ post = path.join(__dirname, '../src/lib');
+
+if (!path.existsSync(post)) {
+ fs.mkdirSync(post, 0777);
+}
+
+
+cli.enable('status', 'help');
+cli.parse({
+ modules: ['m', 'Required: Comma seperated list of modules to pass to YUI().use()', 'string'],
+ filter: ['f', 'The file type to produce: debug, raw, min', 'string', 'min'],
+ version: ['v', 'The YUI version to use', 'string', '3.3.0'],
+ gversion: ['gv', 'The Gallery version to use', 'string'],
+ yui2: ['yui2', 'The YUI2 version to use', 'string', '2.8.0']
+});
+
+var parseUse = function(u) {
+ u = u.replace(/ /g, '').split(',');
+ return u;
+}
+
+cli.main(function() {
+ if (!this.options.modules) {
+ cli.getUsage();
+ return;
+ }
+
+ var opts = this.options;
+ //Hack to make sure loader is in the queue
+ var o = opts.modules.split(',');
+ o.push('loader');
+ opts.modules = o.join(',');
+ var config = {
+ m: opts.modules,
+ v: opts.version,
+ parse: true,
+ filt: opts.filter,
+ '2in3v': opts.yui2
+ };
+ config.env = 'get';
+
+ if (opts.gversion) {
+ config.gv = opts.gversion;
+ }
+ yui3.rls(config, function(err, data) {
+ var size = 0;
+ var d = [],
+ pre = [],
+ count = 0;
+ console.log(data.js);
+ for (var k in data.d) {
+ size += data.d[k].length;
+ if (count < 2) {
+ pre.push(data.d[k]);
+ } else {
+ //d.push(data.d[k]);
+ var parts = k.split('/');
+ //Only test against minned files. all others will be loaded from disk
+ var name = (parts[parts.length - 1]).replace(/-/g, '_').replace('_min.js', '');
+
+ fs.writeFileSync(path.join(post, name + '.js'), data.d[k], encoding='utf8');
+ }
+
+ count++;
+ };
+ fs.writeFileSync(path.join(__dirname, '../src/yui.js'), pre.join('\n'), encoding='utf8');
+
+ console.log('Files: ', d.length);
+ console.log('Build Time: %sms', (new Date()).getTime() - start);
+ });
+
+});
+
@@ -0,0 +1,67 @@
+#!/usr/bin/env node
+
+var yui3 = require('yui3-core@3.3.0').path(),
+ fs = require('fs'),
+ path = require('path'),
+ util = require('util'),
+ noop = function() {},
+ copyFile = function(src, dest, cb) {
+ var is = fs.createReadStream(src);
+ var os = fs.createWriteStream(dest, { flags: 'a+' });
+ util.pump(is, os, cb);
+ },
+ yui3_base = path.join(yui3, 'build'),
+ pre = path.join(__dirname, '../src/yui.js'),
+ post = path.join(__dirname, '../src/lib');
+
+if (!path.existsSync(post)) {
+ fs.mkdirSync(post, 0777);
+}
+
+console.log('Reading Main Directory');
+var dirs = fs.readdirSync(yui3_base);
+
+var preFiles = [];
+var finalFiles = [];
+
+dirs.forEach(function(d) {
+ if (d.indexOf('.') === 0) {
+ return;
+ }
+ files = fs.readdirSync(path.join(yui3_base, d));
+ files.forEach(function(file) {
+ switch (file) {
+ case 'text-data-accentfold-min.js':
+ case 'text-min.js':
+ case 'text-data-wordbreak-min.js':
+ //Non-Ascii Characters, need to fix this in the C file
+ return;
+ }
+ if (d === 'yui' || d === 'loader' || d === 'io') {
+ if (file.indexOf(d + '-min.js') === 0) {
+ preFiles.push(path.join(yui3_base, d, file));
+ }
+ return;
+ } else {
+ if (file.indexOf('-min.js') > 0) {
+ finalFiles.push({ file: path.join(yui3_base, d, file), name: file.replace(/-/g, '_').replace('_min.js', '.js') });
+ }
+ }
+ });
+});
+
+preFiles = preFiles.reverse(); //YUI needs to come first ;)
+
+copyFile(preFiles[0], pre, function() {
+ copyFile(preFiles[1], pre, noop);
+});
+
+var copy = function() {
+ if (finalFiles.length) {
+ var i = finalFiles.pop();
+ copyFile(i.file, path.join(post, i.name), copy);
+ }
+}
+console.log('Copying', finalFiles.length, 'files');
+copy();
+
View
@@ -0,0 +1,23 @@
+#!/usr/bin/env node
+
+var startTime = (new Date()).getTime(),
+ times = [],
+ max = 500;
+
+for (var i = 0; i < max; i++) {
+ var start = (new Date()).getTime();
+ var YUI = require('yui3').YUI;
+ YUI({debug: false}).useSync('yql');
+ var end = (new Date()).getTime();
+ times.push((end - start));
+}
+
+var endTime = (new Date()).getTime(),
+ t = 0;
+times.forEach(function(v) {
+ t += v;
+});
+
+console.log('Test time: ', ((endTime - startTime) / 1000), 'sec');
+console.log('Average Time: ', ((t / max) / 1000), 'sec');
+
View
@@ -0,0 +1,44 @@
+#!/usr/bin/env node
+var util = require('util'),
+ assert = require('assert'),
+ i, start, end, times, startTime, endTime, t,
+ max = 10500;
+
+console.log('Starting C++ Load test with', max, 'requires');
+
+var print = function(i) {
+ var per = Math.round(Math.max((i / max) * 100)),
+ bar = '', o;
+ for (o = 0; o < 50; o++) {
+ if ((o*2) <= per) {
+ bar += '#';
+ }
+ }
+ util.print('\r(' + i + ') ' + per + '% ' + bar);
+}
+
+startTime = (new Date()).getTime();
+times = [];
+
+for (var i = 0; i <= max; i++) {
+ start = (new Date()).getTime();
+ var yui3 = require('../yui');
+ var YUI = yui3.YUI;
+ var Y = YUI({debug: false}).useSync('yql');
+ //assert.ok(Y.YQL);
+ end = (new Date()).getTime();
+ times.push((end - start));
+ print(i);
+}
+
+endTime = (new Date()).getTime();
+t = 0;
+
+times.forEach(function(v) {
+ t += v;
+});
+
+util.print('\r\n');
+console.log('Test time: ', ((endTime - startTime) / 1000), 'sec');
+console.log('Average Time: ', ((t / max) / 1000), 'sec');
+
View
@@ -0,0 +1,47 @@
+#!/usr/bin/env node
+var start = (new Date()).getTime();
+var yui3 = require('yui3-compiled');
+var path = require('path');
+yui3.rls({
+ //m: 'yui,loader,dd,widget,autocomplete,gallery-yql,yui2-datatable,gallery-aui-toolbar',
+ //m: 'yui,loader,dd',
+ //m: 'dd',
+ m: 'loader,dd,widget,autocomplete,gallery-yql,yui2-datatable',
+ //m: 'yui',
+ //env: 'yui',
+ //m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
+ //env: 'node,attribute',
+ //v: 'yui3-core@3.2.0',
+ //v: '3.2.0',
+ //gv: '2010.09.22',
+ //parse: true //This parses the file content and returns it as the last arg
+ //gmeta: __dirname + '/gallery-meta.js',
+ //yui2meta: __dirname + '/2in3-meta.js',
+ //filt: 'debug',
+ //'2in3v': '2.8.0',
+ GlobalConfig: {
+ loaderPath: path.join(__dirname, '..', 'tests', 'extras', '/loader-min.js'),
+ debug: true
+ }
+}, function(err, data) {
+ var end = (new Date()).getTime() - start;
+ console.log('Callback..');
+ console.log(data.js);
+ console.log(data.css);
+ var size = 0;
+ for (var i in data.d) {
+ if (data.d[i]) {
+ size += data.d[i].length;
+ console.log('i: ', i, (data.d[i].length));
+ }
+ }
+ console.log('Total: ', [].concat(data.js, data.css).length);
+ console.log('Total JS: ', data.js.length);
+ console.log('Total CSS: ', data.css.length);
+ console.log('Data: ', Object.keys(data.d).length);
+ console.log('Size: (bytes)', size);
+ console.log('Time: %sms', end);
+
+});
+
+
Oops, something went wrong.

0 comments on commit d1c8c8f

Please sign in to comment.