forked from FooBarWidget/multipart-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
38 lines (33 loc) · 1.05 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
task :default => 'multipart'
file 'multipart' => ['multipart.cpp', 'MultipartParser.h', 'MultipartReader.h'] do
sh 'g++ -Wall -g multipart.cpp -o multipart'
end
file 'random' do
sh "dd if=/dev/urandom of=random bs=1048576 count=100"
end
desc "Create a test multipart file"
task :generate_test_file => 'random' do
output = ENV['OUTPUT']
size = (ENV['SIZE'] || 1024 * 1024 * 100).to_i
boundary = ENV['BOUNDARY'] || '-----------------------------168072824752491622650073'
raise 'OUTPUT must be specified' if !output
puts "Creating #{output}"
File.open(output, 'wb') do |f|
f.write("--#{boundary}\r\n")
f.write("content-type: text/plain\r\n")
f.write("content-disposition: form-data; name=\"field1\"; filename=\"field1\"\r\n")
f.write("foo-bar: abc\r\n")
f.write("x: y\r\n")
f.write("\r\n")
end
sh "cat random >> #{output}"
puts "Postprocessing #{output}"
File.open(output, 'ab') do |f|
f.write("\r\n--#{boundary}--\r\n")
end
end
task :benchmark => 'multipart' do
sh "./multipart"
sh "ruby rack-parser.rb"
sh "node formidable_parser.js"
end