Hello,
I would like to throw open a problem I have to the group - your input would be great:
I have been developing a stock market application that loops through approximately 120000 different scenarios, each time working out the profit and loss for each scenario.
I have found that the more scenarios I run in total, the slower the time taken for each scenario is. This is nothing to do with the core engine, as each time it is processing the same number of data items per scenario.
I was puzzled, but then thought it could be this:
At the end of each scenario run, I add the results to a text string like this:
[scenario run # 0]
output = ""
[then for each scenario run]
output = output + str$(profit for that scenario) + "," + str$(loss for that scenario) + "," + str$(other) + chr$(13)
I hold "output" as a string in memory until all scenarios have finished, then write "output" as a .csv and open in excel to sort the columns.
Could my "output = output +" be slowing the application down?
It could make sense - does PB take a copy of the old string and add the new line to the string each time? - I don't know how PB manages strings. Therefore, as output grows in length, so does the time needed to create a new output string?
However, if PB was doing this, it would explain why my app slows down - ie. the number of scenarios run per minute falls as the number of scenarios tested rises.
Suggestions please - thanks.
Alex
I would like to throw open a problem I have to the group - your input would be great:
I have been developing a stock market application that loops through approximately 120000 different scenarios, each time working out the profit and loss for each scenario.
I have found that the more scenarios I run in total, the slower the time taken for each scenario is. This is nothing to do with the core engine, as each time it is processing the same number of data items per scenario.
I was puzzled, but then thought it could be this:
At the end of each scenario run, I add the results to a text string like this:
[scenario run # 0]
output = ""
[then for each scenario run]
output = output + str$(profit for that scenario) + "," + str$(loss for that scenario) + "," + str$(other) + chr$(13)
I hold "output" as a string in memory until all scenarios have finished, then write "output" as a .csv and open in excel to sort the columns.
Could my "output = output +" be slowing the application down?
It could make sense - does PB take a copy of the old string and add the new line to the string each time? - I don't know how PB manages strings. Therefore, as output grows in length, so does the time needed to create a new output string?
However, if PB was doing this, it would explain why my app slows down - ie. the number of scenarios run per minute falls as the number of scenarios tested rises.
Suggestions please - thanks.
Alex
Comment