Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6651743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:02:51+00:00 2026-05-26T01:02:51+00:00

I’m doing some integrations towards MS based web applications which forces me to fetch

  • 0

I’m doing some integrations towards MS based web applications which forces me to fetch the data to my php application via SOAP which is fine.

I got the structure of a file system in an xml which I convert to an object. All documents have an ID and it’s path. To be able to place the documents in a tree view I’ve built some methods to calculate the documents whereabouts through the files and folder structure. This works fine until I started to try with large file lists.

What I need is a faster method (or way to do things) than a foreach loop.

The method below is the troublemaker.

/**
 * Find parent id based on path
 * @param array $documents
 * @param string $parentPath
 * @return int 
 */
private function getParentId($documents, $parentPath) {
    $parentId = 0;
    foreach ($documents as $document) {
        if ($parentPath == $document->ServerUrl) {
            $parentId = $document->ID;
            break;
        }
    }
    return $parentId;
}
// With 20 documents nested in different folders this method renders in 0.00033712387084961
// With 9000 documents nested in different folders it takes 60 seconds

The array sent to the object looks like this

Array
(
    [0] => testprojectDocumentLibraryObject Object
        (
            [ParentID] => 0
            [Level] => 1
            [ParentPath] => /Shared Documents
            [ID] => 163
            [GUID] => 505d70ea-51d7-4ef0-bf79-8e912553249e
            [DocIcon] => 
            [FileType] => 
            [Title] => Folder1
            [BaseName] => Folder1
            [LinkFilename] => Folder1
            [ContentType] => Folder
            [FileSizeDisplay] => 
            [_UIVersionString] => 1.0
            [ServerUrl] => /Shared Documents/Folder1
            [EncodedAbsUrl] => http://dev1.example.com/Shared%20Documents/Folder1
            [Created] => 2011-10-08 20:57:47
            [Modified] => 2011-10-08 20:57:47
            [ModifiedBy] => 
            [CreatedBy] => 
            [_ModerationStatus] => 0
            [WorkflowVersion] => 1
        )
...

A bit bigger example of the data array is available here
http://www.trikks.com/files/testprojectDocumentLibraryObject.txt

Thanks for any help!

=== UPDATE ===

To illustrate the time different stuff takes I’ve added this part.

  1. Packet downloaded in 8.5031080245972 seconds
  2. Packet decoded in 1.2838368415833 seconds
  3. Packet unpacked in 0.051079988479614 seconds
  4. List data organized in 3.8216209411621 seconds
  5. Standard properties filled in 0.46236896514893 seconds
  6. Custom properties filled in 40.856066942215 seconds
  7. TOTAL: This page was created in 55.231353998184 seconds!

Now, this is a custom property action that im describing, the other stuff is already somewhat optimized. The data sent from the WCF service is compressed and encoded ratio 10:1 (like 10mb uncompressed : 1mb compressed).

The current priority is to optimize the custom properties part, where the getParentId method takes 99% of the execution time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:02:51+00:00Added an answer on May 26, 2026 at 1:02 am

    As usual this was a matter of programming design. And there are a few lessons to be learned from this.

    In a file system the parent is always a folder, to speed up such a process in php you can put all the folders in a separate array with it’s corresponding ID as the key and search that array when you want to find the parent of a file, instead of searching the entire file structure array!

    1. Packet downloaded in 6.9351849555969 seconds
    2. Packet decoded in 1.2411289215088 seconds
    3. Packet unpacked in 0.04874587059021 seconds
    4. List data organized in 3.7993721961975 seconds
    5. Standard properties filled in 0.4488160610199 seconds
    6. Custom properties filled in 0.15889382362366 seconds
    7. This page was created in 11.578738212585 seconds!

    Compare the custom properties by the one from my original post

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.