Замечательно!Lepton писал(а):Язык программирования Euphoria (для вычисления чисел Фибоначчи)
Ссылочку дайте, что это такое Euphoria?
Илив 2 слова: чем оно вам приглянулось?
Модератор: Olej
Замечательно!Lepton писал(а):Язык программирования Euphoria (для вычисления чисел Фибоначчи)
Lepton, а вы для тех языков, что сделали, проделайте параллельно сортировку пузырьком (другой класс задач).Lepton писал(а):Язык программирования Euphoria (для вычисления чисел Фибоначчи)
Код: Выделить всё
$ eubind -out fibo fibo.ex
deleted 239 unused routines and 1017 unused variables.
You may now run ./fibo
$ time ./fibo 30
1346269
real 0m0.646s
user 0m0.625s
sys 0m0.020s
Lepton, меня ваши опыты с Euphoria заинтересовали.Lepton писал(а):Euphoria v4.1.0 (beta)Код: Выделить всё
$ eui -v Euphoria Interpreter v4.1.0 development 64-bit Linux, Using System Memory Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a
Код: Выделить всё
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/intobj/back/be_task.o: In function `ctask_create':
be_task.c:(.text+0xa77): undefined reference to `_00'
/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/intobj/back/be_task.o: In function `start_task':
be_task.c:(.text+0x1086): undefined reference to `_00'
/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/intobj/back/be_runtime.o: In function `ctrace':
be_runtime.c:(.text+0x30dd): undefined reference to `Argc'
/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/intobj/back/be_runtime.o: In function `eu_startup':
be_runtime.c:(.text+0x323a): undefined reference to `Argc'
/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/intobj/back/be_runtime.o: In function `shift_args':
be_runtime.c:(.text+0x3ee5): undefined reference to `Argc'
be_runtime.c:(.text+0x3ef8): undefined reference to `Argv'
be_runtime.c:(.text+0x3f08): undefined reference to `Argv'
be_runtime.c:(.text+0x3f26): undefined reference to `Argv'
/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/intobj/back/be_runtime.o: In function `Command_Line':
be_runtime.c:(.text+0x3f5e): undefined reference to `Argc'
be_runtime.c:(.text+0x3f65): undefined reference to `Argv'
be_runtime.c:(.text+0x3f76): undefined reference to `Argc'
collect2: ошибка: выполнение ld завершилось с кодом возврата 1
make[3]: *** [/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source/build/eui] Ошибка 1
make[3]: Выход из каталога `/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source'
make[2]: *** [interpreter] Ошибка 2
make[2]: Выход из каталога `/home/Olej/Загрузки/Euphoria/euphoria-4.1.0-Linux-ix86-64/source'
make[1]: *** [interpreter] Ошибка 2
Ответ здесь: viewtopic.php?f=26&t=3817&p=11274#p11274Olej писал(а):Lepton, меня ваши опыты с Euphoria заинтересовали.Lepton писал(а):Euphoria v4.1.0 (beta)Код: Выделить всё
$ eui -v Euphoria Interpreter v4.1.0 development 64-bit Linux, Using System Memory Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a
Но вы откуда и как получали вашу программу eui?
Но как вы сделали установку v4.1.0 ?
У меня make слетает по ошибке:
Lepton писал(а):Euphoria v4.1.0 (beta)Код: Выделить всё
$ eui -v Euphoria Interpreter v4.1.0 development 64-bit Linux, Using System Memory Revision Date: 2014-01-16 02:53:44, Id: 5783:d41527402a7a
Код: Выделить всё
[Olej@modules euphoria]$ cat /proc/cpuinfo | grep 'model name'
model name : Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
model name : Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
model name : Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
model name : Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
Код: Выделить всё
[Olej@modules fibo]$ time ./fibo_c 40
165580141
real 0m0.372s
user 0m0.369s
sys 0m0.000s
[Olej@modules fibo]$ time eui fibo.ex 40
165580141
real 0m36.139s
user 0m35.026s
sys 0m0.277s
Lepton писал(а): Связывание в единый исполняемый файл fibo (включает интерпретатор и все необходимые библиотеки):Код: Выделить всё
$ eubind -out fibo fibo.ex deleted 239 unused routines and 1017 unused variables. You may now run ./fibo $ time ./fibo 30 1346269 real 0m0.646s user 0m0.625s sys 0m0.020s
Код: Выделить всё
[Olej@modules fibo]$ eubind -out fibo_ex fibo.ex
deleted 239 unused routines and 1017 unused variables.
You may now run ./fibo_ex
[Olej@modules fibo]$ time ./fibo_ex 40
165580141
real 0m35.591s
user 0m34.869s
sys 0m0.073s
[Olej@modules fibo]$ ls -l fibo_ex
-rwxrwxr-x. 1 Olej Olej 2383177 сен 2 23:00 fibo_ex
В принципе, судя по тому как они нахваливают свою языковую систему, у них должен быть способ компиляции приложения в исполнимую форму. В принципе, трансформация исходного кода в C с последующей компиляцией + оптимизацией - это тоже и есть такой вариант ... только это громоздко, должен быть прямой путь.Lepton писал(а): еще можно сгенерировать (транслятором) исходный код на Си.
http://www.rapideuphoria.com/refman_2.htm#43Olej писал(а): В смысле производительности это, естественно, ничего не добавляет.
Там же написано, что вычисление с использованием переменных, объявленных как integer, будут быстрее, чем с объявленными как atom.Note to Benchmarkers:
When comparing the speed of Euphoria programs against programs written in other languages, you should specify without type_check at the top of the file. This gives Euphoria permission to skip run-time type checks, thereby saving some execution time. All other checks are still performed, e.g. subscript checking, uninitialized variable checking etc. Even when you turn off type checking, Euphoria reserves the right to make checks at strategic places, since this can actually allow it to run your program faster in many cases. So you may still get a type check failure even when you have turned off type checking. Whether type checking is on or off, you will never get a machine-level exception. You will always get a meaningful message from Euphoria when something goes wrong. (This might not be the case when you poke directly into memory, or call routines written in C or machine code.)
Lepton писал(а):Там же написано, что вычисление с использованием переменных, объявленных как integer, будут быстрее, чем с объявленными как atom.Note to Benchmarkers:
When comparing the speed of Euphoria programs against programs written in other languages, you should specify without type_check at the top of the file. This gives Euphoria permission to skip run-time type checks, thereby saving some execution time. All other checks are still performed, e.g. subscript checking, uninitialized variable checking etc. Even when you turn off type checking, Euphoria reserves the right to make checks at strategic places, since this can actually allow it to run your program faster in many cases. So you may still get a type check failure even when you have turned off type checking. Whether type checking is on or off, you will never get a machine-level exception. You will always get a meaningful message from Euphoria when something goes wrong. (This might not be the case when you poke directly into memory, or call routines written in C or machine code.)
Ну в нашем случае это не актуально, с двумя переменными
C without type_check:Olej писал(а):Это сравнение GCC/C и Euphoria в режиме интерпретации. Это мало о чём говорит, ... но для сравнения: 2 порядка.Код: Выделить всё
[Olej@modules fibo]$ time eui fibo.ex 40 165580141 real 0m36.139s user 0m35.026s sys 0m0.277s
Код: Выделить всё
[Olej@modules fibo]$ time eui fibo.ex 40
165580141
real 0m35.047s
user 0m34.059s
sys 0m0.281s
Там не так всё однозначно:Lepton писал(а): p/s Кстати, у меня при компиляции те же ошибки...
Итого, у нас есть 2 класса задач:Olej писал(а): Сделал!
Пока сравнение только 3-х языков, которые меня на сейчас интересуют: C, C++, Go.
И разных компиляторов: GCC + Clang для C, GCCGO + GoLang для Go.
Код: Выделить всё
#include <stdio.h>
#include <stdlib.h>
// ============>
// -|- | |
// --|-- | |
// ---|--- | |
// 1 2 3
char debug = 0;
ulong nopr = 0;
void put( int from, int to ) {
++nopr;
if( !debug ) return;
printf( "%d => %d, ", from, to );
if( 0 == ( nopr % 5 ) ) printf( "\n" );
}
int temp( int from, int to ) { // промежуточная позиция
int i = 1;
for( ; i <= 3; i++ )
if( i != from && i != to )
return i;
return 0; // ошибка
}
void move( int from, int to, int n ) {
if( n > 1 ) move( from, temp( from, to ), n - 1 );
put( from, to ); // единичное перемещение
if( n > 1 ) move( temp( from, to ), to, n - 1 );
}
int main( int argc, char **argv, char **envp ) {
if( argc != 2 )
printf( "usage: %s [-]<number>\n", argv[ 0 ] ), exit( 1 );
int size = atoi( argv[ 1 ] ); // число переносимых фишек
if( size < 0 ) size = -size, debug = 1;
if( debug ) printf( "размер пирамиды: n=%d\n", size );
move( 1, 3, size ); // вот и всё решение!
if( debug && ( nopr % 5 ) != 0 ) printf( "\n" );
printf( "число перемещений %ld\n", nopr );
return 0;
}
Код: Выделить всё
package main
import( "os"; "strconv" )
var debug bool = false
var nopr uint64 = 0
func move( from, to, сколько int ) {
put := func( from, to int ) {
nopr++;
if !debug { return }
print( from, " => ", to, ", " )
if 0 == ( nopr % 5 ) { print( "\n" ) }
}
temp := func( from, to int ) int { // промежуточная позиция
for i := 1; i <= 3; i++ {
if i != from && i != to { return i }
}
panic( 0 ); // ошибка
}
if сколько > 1 { move( from, temp( from, to ), сколько - 1 ) }
put( from, to ) // единичное перемещение
if сколько > 1 { move( temp( from, to ), to, сколько - 1 ) }
}
func main() {
if len( os.Args ) != 2 {
print( "usage: ", os.Args[ 0 ], " [-]<number>\n" )
return
}
debug = false
размер, _ := strconv.Atoi( os.Args[ 1 ] )
if размер < 0 { размер, debug = -размер, true }
if debug { print( "размер пирамиды: n=", размер, "\n" ) }
move( 1, 3, размер ) // вот и всё решение!
if debug && ( nopr % 5 ) != 0 { print( "\n" ) }
print( "число перемещений ", nopr, "\n" )
}
Код: Выделить всё
[Olej@modules hanoy]$ time ./hanoy_c 27
число перемещений 134217727
real 0m2.648s
user 0m2.631s
sys 0m0.002s
[Olej@modules hanoy]$ time ./hanoy_cl 27
число перемещений 134217727
real 0m2.511s
user 0m2.498s
sys 0m0.001s
[Olej@modules hanoy]$ time ./hanoy_go 27
число перемещений 134217727
real 0m5.449s
user 0m5.420s
sys 0m0.010s
[Olej@modules hanoy]$ time ./hanoy_gol 27
число перемещений 134217727
real 0m2.334s
user 0m2.333s
sys 0m0.001s
Сейчас этот форум просматривают: нет зарегистрированных пользователей и 4 гостя