Hirdetés
- Kalandor: „Ha engedtem volna a lelkiismeretemnek, az üzlet kevésbé lett volna jövedelmező”
- gban: Ingyen kellene, de tegnapra
- potyautas: Nóta állj!
- Garry84: Sumák aprós?
- sziku69: Fűzzük össze a szavakat :)
- sziku69: Szólánc.
- Luck Dragon: Asszociációs játék. :)
- f(x)=exp(x): A laposföld elmebaj: Vissza a jövőbe!
- Lalikiraly: Kinek milyen setupja van?
- bambano: Bambanő háza tája
Új hozzászólás Aktív témák
-
F34R
nagyúr
o do that, shells fork the command in a subshell and read its output through a pipe or socketpair. You see a lot of variation here. On a 50MiB file here, I can see for instance bash being 6 times as slow as ksh93 but slightly faster than zsh and twice as fast as yash.
The main reason for bash being slow is that it reads from the pipe 128 bytes at a time (while other shells read 4KiB or 8KiB at a time) and is penalised by the system call overhead.
zsh needs to do some post-processing to escape NUL bytes (other shells break on NUL bytes), and yash does even more heavy-duty processing by parsing multi-byte characters.
All shells need to strip the trailing newline characters which they may be doing more or less efficiently.
Some may want to handle NUL bytes more gracefully than others and check for their presence.
Then once you have that big variable in memory, any manipulation on it generally involves allocating more memory and coping data across.
Here, you're passing (were intending to pass) the content of the variable to echo.
Luckily, echo is built-in in your shell, otherwise the execution would have likely failed with an arg list too long error. Even then, building the argument list array will possibly involve copying the content of the variable.
The other main problem in your command substitution approach is that you're invoking the split+glob operator (by forgetting to quote the variable).
For that, shells need to treat the string as a string of characters (though some shells don't and are buggy in that regard) so in UTF-8 locales, that means parsing UTF-8 sequences (if not done already like yash does), look for $IFS characters in the string. If $IFS contains space, tab or newline (which is the case by default), the algorithm is even more complex and expensive. Then, the words resulting from that splitting need to be allocated and copied.
The glob part will be even more expensive. If any of those words contain glob characters (*, ?, [), then the shell will have to read the content of some directories and do some expensive pattern matching (bash's implementation for instance is notoriously very bad at that).
Nem volt hulyeseg azt mondani probald ki a mksh-t. A fish meg a zsh-tol is lassabb.
Az i valtozo a scriptben pl egy nagy eroforras, ezt lassan fogja neked futtatni.
Új hozzászólás Aktív témák
- HiFi műszaki szemmel - sztereó hangrendszerek
- Tesla topik
- Okos Otthon / Smart Home
- Okosóra és okoskiegészítő topik
- Ubiquiti hálózati eszközök
- Fujifilm X
- Annyira nem rajong az Intel és az NVIDIA közös PC-s projektjéért az Acer
- Xbox Series X|S
- Napelem
- Vezeték nélküli fülhallgatók
- További aktív témák...
- Apple Watch Ultra - garis 2026.01.17-ig
- Szép állapot! LENOVO ThinkPad T14s i7-165G7 / 16GB / 512GB SSD / Windows 11 Pro
- Kitűnő állapot! LENOVO ThinkPad T14s i7-165G7 / 16GB / 512GB SSD / Windows 11 Pro
- ÚJ AKKU! Ár/ÉRTÉK BAJNOK! Dell Latitude 5330 i3-1215U 6mag! 16GB 512GB 13.3" FHD 1 év gar
- Apple watch 8 45mm white aluminium
- Konzol felvásárlás!! Playstation 5, Playstation 5 Pro
- Bomba Ár! HP ProBook 650 G1 - i5-4GEN I 8GB I 500GB I 15,6" HD I Cam I W10 I Garancia!
- Alienware M18 R1 QHD+ IPS 165Hz i9-13900HX 24mag 32GB 1TB Nvidia RTX 4070 8GB 140W Win11 Garancia
- DeepCool CC560 Black V2 garis+ ajándék DeepCool CPU Water Cooler - MYSTIQUE 240 hütö
- DELL Precision Dual USB-C Thunderbolt Dock - TB18DC
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest