dMZX Forums: Directory reading slow? - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Directory reading slow?

#1 User is offline   Old-Sckool 

  • megazeux breaker
  • PipPipPipPip
  • Group: Members
  • Posts: 649
  • Joined: 07-June 05
  • Gender:Male

Posted 19 March 2015 - 05:39 AM

Been working on a small mzx project, and I have noticed that reading directories being really slow. I'm not doing something stupidly wrong am I?

. "open_dir opens a subdirectory"
. "up_dir opens the parent directory if it has permission"
. "top_dir opens the top-level directory"

color c11
set "$dir_s&dir_s&" to "."
inc "dir_s" by 1


: "set_dir"
set "f" to 0
set "file" to 0
set "dir" to 1
set "ui_dir" to 0
set "ui_file" to 0
set "$dir0" to ".."

set "$dir" to ""
loop start
inc "$dir" by "&$dir_s('loopcount')&"
inc "$dir" by "/"
loop for "('dir_s'-1)"

set "&$dir&" to "fread_open"

: "readdir_l"
set "$buffer" to "fread"
if "$buffer.length" = 0 then "readdir_s"
set "$f&f&" to "$buffer"
inc "f" by 1
goto "readdir_l"

: "readdir_s"
set "" to "fread_open"
if "f" != 0 then "#sortfiles"
end

: "open_dir"
if "$newdir" = ".." then "up_dir"
set "$dir_s&dir_s&" to "$newdir"
inc "dir_s" by 1
set "scroll_new_list_event" to 1
goto "set_dir"

: "up_dir"
if "dir_s" = 1 then "end"
dec "dir_s" by 1
set "scroll_new_list_event" to 1
goto "set_dir"

: "end"
end


: "#sortfiles"
loop start
set "$f" to "$f&loopcount&"
set "&$dir&/&$f&" to "fread_open"
set "fread_pos" to -1
if "fread_pos" = -1 then "sortfiles_s"
if "fread_pos" = 0 then "sortfiles_dir"

set "$file&file&" to "$f"
inc "file" by 1
goto "sortfiles_s"

: "sortfiles_dir"
set "$" to "fread"
if "$.length" = 0 then "sortfiles_s"

set "$dir&dir&" to "$f"
inc "dir" by 1

: "sortfiles_s"
set "" to "fread_open"
loop for "('f'-1)"
goto "#return"

Attached File(s)


<Nadir> mzxers don't make GAMES, usually
<phthalocyanine> they make experiences.
<Nadir> demos, more like
<Nadir> a glimpse into what could have been if mzx wasn't such a bore to work with
<Nadir> actually, i'm being unfair
<Nadir> i would have made mzx games if it was capable of running on more than 20 computers worldwide in 1998
<Nadir> >:D

<%Alice> functor
<%nooodl> i hear C++ has a thing called functors and they're completely different from Haskell functors...
<rorirover> the result is the most horrid thing in C++, it's basically black magic and it transforms any code you're writing into some eldritch monstrosity
0

#2 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,936
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 19 March 2015 - 07:06 AM

i assume commands isn't really low or anything like that

in which case it looks fine and maybe opening lots of files is slow for some reason? if so that's a shame because it makes what you're doing infeasible. in c etc you'd use stat to find out if something's a dir, so this wouldn't be something i've tried to do before

i'll try running it when i get home

EDIT: just tested it and i don't know what the performance problem is

the initial directory, my main mzx directory takes a little bit to load, but it's only a tiny fraction of a second (for a dir with 1102 files and dirs in it) and the subdirs i tried load instantly. that sort of delay seems pretty reasonable, especially to open and close that many files

what sort of load are you testing it on and what sort of delays are you experiencing?
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#3 User is offline   Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 19 March 2015 - 01:10 PM

sounds like commands is low or your drive is really slow :(
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository
0

#4 User is offline   Old-Sckool 

  • megazeux breaker
  • PipPipPipPip
  • Group: Members
  • Posts: 649
  • Joined: 07-June 05
  • Gender:Male

Posted 19 March 2015 - 09:08 PM

welp, my system is dead
<Nadir> mzxers don't make GAMES, usually
<phthalocyanine> they make experiences.
<Nadir> demos, more like
<Nadir> a glimpse into what could have been if mzx wasn't such a bore to work with
<Nadir> actually, i'm being unfair
<Nadir> i would have made mzx games if it was capable of running on more than 20 computers worldwide in 1998
<Nadir> >:D

<%Alice> functor
<%nooodl> i hear C++ has a thing called functors and they're completely different from Haskell functors...
<rorirover> the result is the most horrid thing in C++, it's basically black magic and it transforms any code you're writing into some eldritch monstrosity
0

#5 User is offline   Giel 

  • Right this way, M'lady.
  • PipPipPip
  • Group: Members
  • Posts: 237
  • Joined: 25-December 08
  • Gender:Not Telling
  • Location:Like I'm EVER going to tell you.

Posted 22 March 2015 - 10:58 PM

My main MZX directory only loads slowly due to the fact that I have alot of MZX related files in it. Though it only loads slowly a couple times, then it loads up quickly. Depends on the length of how long the MZX session is anyway. Course, its not TOO slow anyway. especially considering my current machine is an 1.6 GHz Dual Core laptop.

This post has been edited by Giel: 22 March 2015 - 11:00 PM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users