Войти в систему

Home
    - Создать дневник
    - Написать в дневник
       - Подробный режим

LJ.Rossia.org
    - Новости сайта
    - Общие настройки
    - Sitemap
    - Оплата
    - ljr-fif

Редактировать...
    - Настройки
    - Список друзей
    - Дневник
    - Картинки
    - Пароль
    - Вид дневника

Сообщества

Настроить S2

Помощь
    - Забыли пароль?
    - FAQ
    - Тех. поддержка



Пишет nancygold ([info]nancygold)
@ 2024-08-15 17:15:00


Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Настроение: amused
Entry tags:computing

Optimized it a bit...

$ time ./symta.exe -e 'I 0; while I < 1000000000: ++I; say I'
1000000000
No
real    0m 11.70s
user    0m 1.96s
sys     0m 0.00s



If we believe the Anon at https://lj.rossia.org/users/nancygold/192317.html?thread=1546301#t1546301

it is 10 times slower than the compiled code, which I think is near the limit for the interpreted code.


(Добавить комментарий)


(Анонимно)
2024-08-15 17:53 (ссылка)
We don't have the same cpu though. I have desktop AMD 7950x. You have some recent intel laptop cpu. They have similar geekbench scores, but not exactly the same. Also I disabled boosting beyond 4.5 or 4.7 GHz (don't remember exactly) in the bios, so it's slower than the default desktop configuration.

(Ответить) (Ветвь дискуссии)


[info]nancygold
2024-08-15 18:52 (ссылка)
>AMD 7950x
Mine is Intel Core i7-12700H
But I don't think it is orders of magnitude slower than a desktop CPU.
But yeah, CPU can have some microcode optimizations for simpler loops.
So iterating over integers isnt guaranteed to represent the general speed.

(Ответить) (Уровень выше) (Ветвь дискуссии)


(Анонимно)
2024-08-15 19:46 (ссылка)
>orders of magnitude slower

It isn't. It's actually shouldn't be much slower at all. About the same for single threaded tasks. But different architectures are different architectures and could differ significantly from task to task (in tens of percent), enough to render comparative measurement as irrelevantly inaccurate.

(Ответить) (Уровень выше)


(Анонимно)
2024-08-15 17:54 (ссылка)
>limit for the interpreted code.

class ArrogantSadkov {
public static void main(String[] args) {
int i = 0;

while (i<1000000000) i++;

System.out.println(i);
}
}

time java -Djava.compiler=NONE ArrogantSadkov
1000000000

real 0m3.779s
user 0m3.763s
sys 0m0.010s

(Ответить) (Ветвь дискуссии)


(Анонимно)
2024-08-15 17:55 (ссылка)
$ java --version
openjdk 17.0.11 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)

(Ответить) (Уровень выше)


(Анонимно)
2024-08-15 17:57 (ссылка)
I mean maybe you meant limit for a dynamically typed language.

(Ответить) (Уровень выше)


[info]nancygold
2024-08-15 18:53 (ссылка)
Can you compile it with proper optimizations? I can't believe Java is slower than a fucking Node.js.

(Ответить) (Уровень выше) (Ветвь дискуссии)


(Анонимно)
2024-08-15 19:27 (ссылка)
It's slower because it's being interpreted, undermining your "it's the limit" argument. See the "-Djava.compiler=NONE" flag. Without the "-Djava.compiler=NONE" flag:

$ time java ArrogantSadkov
1000000000

real 0m0.026s
user 0m0.014s
sys 0m0.013s

(Ответить) (Уровень выше) (Ветвь дискуссии)


(Анонимно)
2024-08-15 19:50 (ссылка)
And the compiler optimized the loop out in this case.

(Ответить) (Уровень выше)