This discussion is archived
2 Replies Latest reply: Oct 12, 2011 11:38 AM by 833233 RSS

mkdir method of File API consuming more time while creating subdirectorie

833233 Newbie
Currently Being Moderated
Hi ,

I am using Java 1.5
OS is Linux
storage is NFS mounted.

As per a requirement I am trying to create a subdirectories with depth as 5 to store files and each time new directory structure should be created. I am able to see that mkdir() method of File API consumes more time in creating directories. As per test conducted i could see the a variation of 5 to 45 milliseconds being spent on creating directories.

Can any one please suggest if there can be a efficient way of creating directory structure with depth specified as 5 and can be achieved within 1-2 milliseconds

Kindly please provide your suggestion.


Thanks
Really appreciate it.
  • 1. Re: mkdir method of File API consuming more time while creating subdirectorie
    796440 Guru
    Currently Being Moderated
    user13789832 wrote:
    I am able to see that mkdir() method of File API consumes more time in creating directories.
    More time than what?
    Can any one please suggest if there can be a efficient way of creating directory structure with depth specified as 5 and can be achieved within 1-2 milliseconds
    There's no way to guarantee how long it will take. That depends entirely on your environment. If you're creating more than one deep, you might find you get better performance with mkdirs() to create A, B, and C and once, rather than calling mkdir("A"), then mkdir("A/B"), then mkdir("A/B/C").

    Otheriwse, no there's no way to make it go faster. If 5-45 ms. is not fast enough (Which sounds really odd! What are you doing that requires you to create directories 5 deep more than 200 times per second?), then you'll just have to pre-create them, or hope that you've got enough spare CPU and I/O available between bursts to create them in a separate thread.

    (And other than that very last suggestion of mine, this question has nothing to do with Concurrency. It's more of an I/O question.)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points