J'ai recommencé mes tests mais cette fois-ci avec ma machine personnelle
et après modif du script python pour qu'il soit un tant soit peu plus
performant, mais tout en restant lisible et compréhensible.
Par la même occasion, j'ai fais l'exerice avec un programme Eiffel (le
compilo est smarteiffel 1.1 avec l'option de compilation -boost).
Comme Edgar, j'ai aussi utilisé strace -c pour obtenir le nombre
d'appels syst.
J'ai effectué tests sur 5 échantillons et entre chaque le fichier de
sortie est supprimé.
Le fichier en entrée est de 480 lignes.
Ma machine:
Debian GNU/Linux sarge, Athlon XP 1700+, 1Go RAM, noyau 2.6.10 compilé
par mes soins à partir des sources de Debian.
Voici les résultats :
Perl Python Ruby Eiffel
real 0m0.009s 0m0.026s 0m0.016s 0m0.002s
user 0m0.003s 0m0.017s 0m0.010s 0m0.001s
sys 0m0.003s 0m0.006s 0m0.004s 0m0.002s
syscalls 132 585 1115 47
Ci-joint les sources des programmes et le fichier en entrée.
--
Miguel Moquillon <miguel.moquillon@???>
jabber://moqui@???
http://miguel.moquillon.free.fr
#!/usr/bin/perl
my ($file_in, $file_out, $text) = (@ARGV[0], @ARGV[1],'');
open (MY_FILE, "<$file_in") or die "Cannot open file $file_in\n";
while (<MY_FILE>) {
s/\n/ / if (($. - 1) % 2 == 0);
$text .= $_;
}
close (MY_FILE);
open (RESULT_FILE, ">$file_out") or die "Cannot open file $file_out\n";
print RESULT_FILE $text or die "Cannot write data in file $file_out\n";
close (RESULT_FILE);
#!/usr/bin/env python
import sys
file_in, file_out, text, i = sys.argv[1], sys.argv[2], '', 1
try:
my_file = open( file_in, 'r' )
for line in my_file:
if i % 2:
text += line.replace("\n", " ")
else:
text += line
i = i + 1
my_file.close()
except:
print 'Cannot open file ' + file_in + '\n'
sys.exit( 1 )
try:
my_file = open( file_out, 'w' )
my_file.write( text )
my_file.close()
except:
print 'Cannot open file' + file_out + '\n'
sys.exit( 1 )
#!/usr/bin/env ruby
file_in, file_out, text, i = ARGV[0], ARGV[1], '', 0
begin
File.foreach file_in do |line|
line.gsub! "\n", " " if i % 2 == 0
text << line
i = i + 1
end
rescue
print "Cannot open file #{file_in}\n"
Kernel.exit 1
end
begin
my_file = File.open file_out, "w"
my_file << text
my_file.close
rescue
print "Cannot open file #{file_out}\n"
Kernel.exit 1
end
class LINE_FEED_REMOVER
-- A LINE_FEED_REMOVER objects aim to remove every 2 lines
-- a line feed. The line feed remove is done by becoming with
-- the first line
creation make
feature
make is
-- The main feature of the class.
local
file_in : TEXT_FILE_READ
file_out: TEXT_FILE_WRITE
line : INTEGER
text : STRING
do
create file_in.connect_to (argument(1))
create text.make (2048)
from line := 0 until file_in.end_of_input loop
file_in.read_line
if line \\ 2 = 0 then
text.append (file_in.last_string + " ")
else
text.append (file_in.last_string + "%N")
end
line := line + 1
end
file_in.disconnect
create file_out.connect_to (argument(2))
file_out.put_string (text)
file_out.disconnect
rescue
print ("Error - Cannot open " + argument (1) + " or " + argument (2))
die_with_code (exit_failure_code)
end
end
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true
#Sun Dec 05 21:57:24 UTC 2004
basic.class.set_font_bold=false
ui.window.location.y=262
ui.window.location.x=154
jude.recentfile4=
jude.recentfile3=
basic.sequence_flat_index=false
jude.recentfile2=
jude.recentfile1=
jude.recentfile0=
file.compress_save=true
uml.stereotype.color.8=\#FFFFFF
uml.stereotype.color.7=\#FFFFFF
uml.stereotype.color.6=\#FFFFFF
uml.stereotype.color.5=\#FFFFFF
uml.stereotype.color.4=\#FFFFFF
uml.stereotype.color.3=\#FFFFFF
uml.stereotype.color.2=\#FFFFFF
uml.stereotype.color.1=\#FFFFFF
uml.stereotype.color.0=\#FFFFFF
ui.window.size.height=730
basic.change_direction_of_relation=false
grid.interval_y=30
grid.interval_x=30
basic.editor.show_scrollbar=true
basic.remove_invalid_recent_filenames=true
basic.collaboration_flat_index=false
ui.look_and_feel=javax.swing.plaf.metal.MetalLookAndFeel
ui.javadir=java.lang.Object@1705316comlapoudre\\players
basic.package.default_name_in_body=true
uml.stereotype.name.8=
uml.stereotype.name.7=
uml.stereotype.name.6=
uml.stereotype.name.5=
uml.stereotype.name.4=entity
uml.stereotype.name.3=control
uml.stereotype.name.2=boundary
uml.stereotype.name.1=interface
uml.stereotype.name.0=actor
basic.editor.do_auto_pan_to_show=true
grid.color=\#CCCCFF
ui.window.size.width=980
jude.recentfilenum=0
ui.workdir=/home/miguel/tmp
basic.activity_synchronization_independent=false
grid.diagram_visibility=false
basic.allow_multi_editor=false
basic.map.mouse_operation=true