Skip to content
This repository was archived by the owner on Oct 10, 2026. It is now read-only.

Commit b051c7e

Browse files
author
Manuel Eusebio de Paz Carmona
committed
Script shell launching samples
1 parent b4db05e commit b051c7e

4 files changed

Lines changed: 73 additions & 40 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# launch test with timming report
2+
3+
echo "node output (async)"
4+
node mysql_insert_loop.js
5+
6+
#echo "python output (sync mono thread)"
7+
#python mysql_insert_loop.py
8+
9+
echo "Reports"
10+
echo "node output (async)"
11+
time node mysql_insert_loop.js >> /dev/null
12+
echo "python output (sync mono thread)"
13+
time python mysql_insert_loop.py >> /dev/null

‎P02_nodejsutilities/benchmarks/mysql_insert_loop.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var insert_random_element=function(){
77
port : 3306,
88
database: 'node_test',
99
user : 'root',
10-
password : 'admin'
10+
password : 'temporal'
1111
});
1212
connection.connect(function(err){
1313
if(err != null){
@@ -20,7 +20,7 @@ var insert_random_element=function(){
2020
console.error("Query error:" + err);
2121
} else {
2222
try{
23-
console.log(rows[0]);
23+
//console.log(rows[0]);
2424
console.log("Success!");
2525
}catch(e){}
2626
}
@@ -29,5 +29,5 @@ var insert_random_element=function(){
2929
}
3030

3131

32-
for(var i=50;i-->0;)insert_random_element();
32+
for(var i=100;i-->0;)insert_random_element();
3333
//process.exit(code=0)

‎P02_nodejsutilities/benchmarks/mysql_insert_loop.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import time,mysql.connector
44

5-
for i in xrange(50):
5+
for i in xrange(100):
66
conn = mysql.connector.connect(host= "localhost",
77
user="root",
8-
passwd="admin",
8+
passwd="temporal",
99
db="node_test")
1010
try:
1111
x = conn.cursor()
@@ -14,4 +14,4 @@
1414
conn.close()
1515
print "element inserted"
1616
except:
17-
print "errorrrrrrrrrrrrrr"
17+
print "error"
Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,61 @@
11
var httpProxy = require('http-proxy'), connect = require('connect'), http = require('http'), fs = require('fs'), mkdirp = require('mkdirp')
2+
var bhost = "www.bbva.com", bport = 80, record_dir = "www2"
23

3-
var bhost="www.bbva.com", bport=80, record_dir="www2"
4+
connect.createServer(connect.static(record_dir)).listen(8000);
45

5-
connect.createServer( connect.static(record_dir)).listen(8000);
6-
7-
httpProxy.createServer(function (req, res, proxy) { //WORKING PROXY
8-
if(req.url.match(/\.css\?*/)){
9-
proxy.proxyRequest(req, res, { host: 'localhost', port: 8000 })
10-
} else {
11-
proxy.proxyRequest(req, res, { host: bhost, port: bport })
12-
//try to go to localhost:9001/TLBB/tlbb/esp/index.jsp
13-
}
6+
httpProxy.createServer(function(req, res, proxy) { // WORKING PROXY
7+
if (req.url.match(/\.css\?*/)) {
8+
proxy.proxyRequest(req, res, {
9+
host : 'localhost',
10+
port : 8000
11+
})
12+
} else {
13+
proxy.proxyRequest(req, res, {
14+
host : bhost,
15+
port : bport
16+
})
17+
// try to go to localhost:9001/TLBB/tlbb/esp/index.jsp
18+
}
1419
}).listen(9001);
1520

21+
httpProxy.createServer(
22+
function(req, res, proxy) { // RECORDING MODE PROXY
23+
if (req.url.match(/\.css\?*/)) {
24+
var options = {
25+
host : bhost,
26+
port : bport,
27+
path : '/' + req.url
28+
}
29+
var request = http.get(options, function(res2) {
30+
var imagedata = ''
31+
var dir_array = options.path.split("/")
32+
var filename = dir_array.pop()
33+
res2.setEncoding('binary')
1634

17-
httpProxy.createServer(function (req, res, proxy) { //RECORDING MODE PROXY
18-
if(req.url.match(/\.css\?*/)){
19-
var options = { host: bhost , port: bport , path: '/'+req.url}
20-
var request = http.get(options, function(res2){
21-
var imagedata = ''
22-
var dir_array=options.path.split("/")
23-
var filename=dir_array.pop()
24-
res2.setEncoding('binary')
25-
26-
res2.on('data', function(chunk){ imagedata += chunk })
27-
28-
res2.on('end', function(){
29-
mkdirp(record_dir+dir_array.join("/"), function(err) { });
30-
fs.writeFile(record_dir+options.path, imagedata, 'binary', function(err){
31-
if (err){ console.log("error saving file: ", err) }
32-
console.log('File saved:',filename)
33-
})
34-
})
35-
})
36-
proxy.proxyRequest(req, res, { host: bhost, port: bport })
37-
} else {
38-
proxy.proxyRequest(req, res, { host: bhost, port: bport})
39-
}
40-
}).listen(9002);
35+
res2.on('data', function(chunk) {
36+
imagedata += chunk
37+
})
4138

39+
res2.on('end', function() {
40+
mkdirp(record_dir + dir_array.join("/"), function(err) {
41+
});
42+
fs.writeFile(record_dir + options.path, imagedata,
43+
'binary', function(err) {
44+
if (err) {
45+
console.log("error saving file: ", err)
46+
}
47+
console.log('File saved:', filename)
48+
})
49+
})
50+
})
51+
proxy.proxyRequest(req, res, {
52+
host : bhost,
53+
port : bport
54+
})
55+
} else {
56+
proxy.proxyRequest(req, res, {
57+
host : bhost,
58+
port : bport
59+
})
60+
}
61+
}).listen(9002);

0 commit comments

Comments
 (0)