简体   繁体   中英

Executing a script takes so long on Git Bash

I'm currently executing a script on Git Bash on a Windows 7 VM. The same script is executed within 15-20 seconds on my Mac machine, but it takes almost 1 hour to run on my Windows.

The script itself contains packages that extract data from XML files, and does not call upon any APIs or anything of the sort.

I have no idea what's going on, and I've tried solving it with the following answers, but to no avail:

I would like to have someone help me out in diagnosing or giving a few pointers on what I could do to either understand where the issue is, or how to resolve it altogether.

EDIT: I am not able to share the entire script, but you can see the type of commands that the script uses through previous questions I have asked on Stackoverflow. Essentially, there is a mixture of XMLStarlet commands that are used.

EDIT2: As a high level overview, the script essentially loops over a folder for XML files, and then retrieves certain data from each one of those files, before creating an HTML page and pasting that data in tables.

A breakdown of these steps in terms of the code can be seen below:

Searching folder for XML files and looping through each one

for file in "$directory"*
do
    if [[ "$file" == *".xml"* ]]; then
        filePath+=( "$file" )
    fi
done

for ((j=0; j < ${#filePath[@]}; j++)); do

    retrieveData "${filePath[j]}"

done

Retrieving data from the XML file in question

function retrieveData() {
    filePath=$1

    # Retrieve data from the revelent xml file
    dataRow=$(xml sel -t -v "//xsd:element[@name=\"$data\"]/@type" -n "$filePath")

    outputRow "$dataRow"
}

Outputting the data to an HTML table

function outputRow() {
    rowValue=$1

    cat >> "$HTMLFILE" << EOF
        <td>
            <div>$rowValue</div>
        </td>
EOF
}

As previously mentioned, the actual xml commands used to retrieve the relevant data can differ, however, the links to my previous questions have the different types of commands used.

Your git-bash installation is out of date.

Execute git --version to confirm this. Are you using something from before 2.x?

Please install the latest version of git-bash , which is 2.24.0 as of 2019-11-13.

See the Release Notes for git for more information about performance improvements over time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM