|
crashdome posted:I'm interested in improving performance of some CPU bound functions. The functions are already async and my UI is responsive. it's just the tasks can take several minutes. Its a procedure which optimizes order and placement of materials. Running all possible combinations is complicated as is the scoring to determine best fit. Would using F# in any way improve performance on procedures that rely heavily on loops and lists as containers? This sounds like a problem for a better algorithm, not switching programming languages (and also sounds vaguely similar to some Hard Problems like the Knapsack Problem but I don't know). RICHUNCLEPENNYBAGS fucked around with this message at 21:56 on Apr 17, 2015 |
# ? Apr 17, 2015 21:11 |
|
|
# ? Jun 6, 2024 23:35 |
|
I think you're right about checking with a profiler first. I'm going to write my changes very deliberately in C# first with very verbose code and after running the profiler I will whittle it down to less verbose linq and/or extension methods to ensure I'm not doing like you said and dumping out too many lists. I have linq sprinkled around inconsistently and that's probably my problem.
|
# ? Apr 17, 2015 21:55 |
|
crashdome posted:I think you're right about checking with a profiler first. I'm going to write my changes very deliberately in C# first with very verbose code and after running the profiler I will whittle it down to less verbose linq and/or extension methods to ensure I'm not doing like you said and dumping out too many lists. I have linq sprinkled around inconsistently and that's probably my problem. Although it does not usually matter, if you have really performance-critical code, you probably want to avoid Linq altogether. Any list or array allocation is obviously linear-time too so avoiding that would help. Another one I see all the time: if you're creating a collection just to check if it contains things, use a HashSet and not a List or array.
|
# ? Apr 17, 2015 21:58 |
|
A read through the Roslyn Contribution Guide might help some. A lot of this stuff will make your code harder to read. There's also LinqOptimizer which will compile your LINQ queries down to IL. I have not used LinqOptimizer but I think someone on SA had
|
# ? Apr 17, 2015 22:06 |
|
crashdome posted:I think you're right about checking with a profiler first. I'm going to write my changes very deliberately in C# first with very verbose code and after running the profiler I will whittle it down to less verbose linq and/or extension methods to ensure I'm not doing like you said and dumping out too many lists. I have linq sprinkled around inconsistently and that's probably my problem. I wouldn't even bother with that. You might run the profiler on your code as-is and discover that 99% of CPU-time is spent in just one tiny five-line chunk of code. No point rewriting the rest of your code if this is the only problem area.
|
# ? Apr 17, 2015 22:09 |
|
ljw1004 posted:I wouldn't even bother with that. You might run the profiler on your code as-is and discover that 99% of CPU-time is spent in just one tiny five-line chunk of code. No point rewriting the rest of your code if this is the only problem area. While that's possible, he described it as a brute-force solution to a combinatorial optimization problem, which suggests to me that the asymptotic complexity is probably super-high.
|
# ? Apr 17, 2015 22:23 |
|
Why does TabControl rebuild the visual tree for its items if you use ItemsSource? Who thought this would be a good idea? I'm using MVVM with AvalonDock and because of this there is a noticeable delay when switching tabs. I don't know how to solve this in a way that isn't really loving hacky.
|
# ? Apr 19, 2015 00:56 |
|
Persist the Visual Tree when switching tabs in the WPF TabControl? Not sure if you'd count this as hacky, but I guess that's WPF for ya vv
|
# ? Apr 20, 2015 09:08 |
|
SirViver posted:Persist the Visual Tree when switching tabs in the WPF TabControl? Perhaps by disabling the document tab binding and doing that with some code behind. I'm more irritated that I have to do this in the first place than anything really. Inverness fucked around with this message at 12:50 on Apr 20, 2015 |
# ? Apr 20, 2015 12:42 |
|
Weird issue. Thiscode:
"saving photos 89" and 89 photos most of the time... I just caught it outputting the 89 photos, plus 2 other batches of previously output photos from a couple days ago... over and over. The correct new batch, plus 2 'stuck' batches. Each time... but always saying that photolist.photos.count was 89.
|
# ? Apr 21, 2015 01:45 |
|
bobua posted:Weird issue. This What is the Write method you're calling doing?
|
# ? Apr 21, 2015 01:58 |
|
Super simple foreach photo in photolist photo.save(); I would normally write that task.run line as Task.Run(() => { filewriter.Write(photolist); }); Instead of how it is... does that make any difference? Could the .write task me crashing silently and hanging around in memory or something? This is bizarre.
|
# ? Apr 21, 2015 02:17 |
|
Your filewriter... is it being shared across photolists? Is the IO operation being disposed of properly?
|
# ? Apr 21, 2015 02:53 |
|
ljw1004 posted:I wouldn't even bother with that. You might run the profiler on your code as-is and discover that 99% of CPU-time is spent in just one tiny five-line chunk of code. No point rewriting the rest of your code if this is the only problem area. RICHUNCLEPENNYBAGS posted:While that's possible, he described it as a brute-force solution to a combinatorial optimization problem, which suggests to me that the asymptotic complexity is probably super-high. Yes, I should mention most of the rewriting is required because of a big change in the algorithm. I just plan on rewriting very verbosely to make it easier to find that 4-5 line chunk of code of why it takes so long and go from there.
|
# ? Apr 21, 2015 03:03 |
|
crashdome posted:Your filewriter... is it being shared across photolists? Is the IO operation being disposed of properly? I think it is, depending on what exactly that means... there is one filewriter object and I give it photolists. The photolist also has a string property that holdes the filename stub, so while one photolist object could be holding more files than it should(say 2 or 3 sets of 89 photos) it couldn't manage to output them under a different name... The best way I can describe how this is acting, is that filewriter is a multicast delegate holding 2 old filewriter's and the one current one. Then everytime I call it it spits out the 2 old ones and the new current one. I'm not using delegates or even events at all though. I only use the word FileWriter twice in my project, once in the constructor with a standard FileWriter filewriter = new FileWriter(); and once more when I call it in the previously posted code. The only think wacky that I do is use some copy\pasted code to try and force a higher quality jpeg save. Here's the whole filewriter class. code:
|
# ? Apr 21, 2015 03:36 |
|
crashdome posted:Your filewriter... is it being shared across photolists? Is the IO operation being disposed of properly? Let's go back a step: Why is he using Task.Run to save a file? [edit] Also, this is a bug just waiting to happen: code:
string videofilenamestub = Properties.Settings.Default.ImagePath + "\\video\\"; New Yorp New Yorp fucked around with this message at 03:42 on Apr 21, 2015 |
# ? Apr 21, 2015 03:40 |
|
bobua posted:Weird issue. This I think the message you write to the log is misleading. How about this one... code:
code:
|
# ? Apr 21, 2015 03:59 |
|
What he said ^^^
|
# ? Apr 21, 2015 04:02 |
|
I thought that defining "async" methods that were just thin wrappers around Task.Run was considered bad practice?
|
# ? Apr 21, 2015 05:03 |
|
GrumpyDoctor posted:I thought that defining "async" methods that were just thin wrappers around Task.Run was considered bad practice? Indeed, though moreso for public methods since it's better to let the caller choose whether or not to use Task.Run. If it's just a private helper method then it might not be so bad (depending on context).
|
# ? Apr 21, 2015 05:44 |
|
Ithaqua posted:Let's go back a step: Saving the files takes 3 to 5 seconds and locks up the other thread which is receiving images from hardware that I need to receive and discard(or they get queued up in a buffer on the hardware). I've read io bound tasks shouldn't be handled with threads but everytime I try some other solution I tend to create a problem elsewhere. I really do want to fire and forget this task, even if it fails. I don't really understand async, but it always seems like they just let the calling method keep processing while waiting, and my calling method is a callback from a driver api. I need it to finish running before the write process finishes.
|
# ? Apr 21, 2015 16:29 |
|
Ithaqua posted:
This isn't my code and I don't like having to use it but it was all google turned up on saving emgu's images to higher quality jpegs than default. Can you give me any help on why it's bad?
|
# ? Apr 21, 2015 16:43 |
|
Can you post more code? I'm still not sure what is going on. You saying "multicast delegate holding 2 old filewriter's and the one current one" has me worried. A Bitmap is not very threadsafe (SO) and it's possible you are getting into a dead lock. For the code Ithaqua mentioned having unbraced loops and if statements can be a "bad" thing (see goto fail SSL exploit). I would at least change it to a LINQ statement so that it's more declarative. Really, I would have the constructor find the ImageCodecInfo and cache it or wrap it in a Lazy<T>. Just to reduce the amount of work needed when saving a JPEG and it's one less call within saveJpeg plus null checking. I would also want to throw an exception if no ImageCodecInfo is found instead of silently giving up or at least log it.
|
# ? Apr 21, 2015 17:06 |
|
bobua posted:This isn't my code and I don't like having to use it but it was all google turned up on saving emgu's images to higher quality jpegs than default. Can you give me any help on why it's bad? If I had to guess, it's the lack of braces around not just just the for loop, but also the if statement. It makes it really easy to unintentionally break things when modifying the code since just adding a line changes the semantics of the loop. EDIT: A clearer and less error-prone way of writing it is to just use LINQ's FirstOrDefault: C# code:
Bognar fucked around with this message at 19:30 on Apr 21, 2015 |
# ? Apr 21, 2015 18:29 |
|
gariig posted:Can you post more code? I'm still not sure what is going on. You saying "multicast delegate holding 2 old filewriter's and the one current one" has me worried. A Bitmap is not very threadsafe (SO) and it's possible you are getting into a dead lock. Thanks. I think I just figured it out the whole problem. I'm registering a callback with the camera's api but never removing it at close. I thought the api shutdown command would kill all that, but it must not because it makes perfect sense with the symptoms I'm getting.
|
# ? Apr 21, 2015 18:36 |
|
We are trying to get more information on replication during our software’s installation that sets up such things. I am trying to get it to log the replication information to a file, and to log all errors and progress. We use the Transpublication.CreateSnapshotAgent method to create the agent. I am trying to get to the Replication Snapshot Agent's parameters, specifically, [-Output output_path_and_file_name] and [-OutputVerboseLevel [0|1|2] ]. So is there a way to access the parameters through C# in the installer code? Or will I have to use a T-SQL script with the PreSnapshotScript and PostSnapshotScript properties to alter the Snapshot Agent and then set it back to default?
|
# ? Apr 21, 2015 23:02 |
|
After tremendous amounts of suffering, I fixed my problem with AvalonDock tabs and the visual tree binding. I did it by creating a ContentControl subclass that creates and caches content presenters, and then replacing the control template for the document pane so it uses that. Edit: So I realized on the way home this wasn't such a great idea. Binding to the source items for the tabs is the only reliable way of keeping track of things instead of the whole weak reference thing I was trying. Instead I want to use an ItemsControl, specifically, the Selector subclass. Only problem is that I can't figure out how to get scroll views to work inside of each item. I want the scroll view inside each item, not an item presenter inside a scroll view. Inverness fucked around with this message at 00:21 on Apr 23, 2015 |
# ? Apr 22, 2015 16:23 |
|
Trying to relearn WPF and MVVM, and binding is still confusing me a bit. I have an enum called Status in my view model, with possible values of READY and OPENING (and more later). Instead of those, I want to display pretty values in my application's status bar, like "Ready." and "Opening (45%)", for example. Is the way forward to bind a label to the enum normally, write a StatusValueConverter with the strings coded in, and set the label's converter to it? Or is there a better way? Ideally, that 45% would come from the OpenProgress property in my view model. (edit) Sorry I can't post any code, separate computers for 'net access here. Ciaphas fucked around with this message at 00:11 on Apr 23, 2015 |
# ? Apr 23, 2015 00:07 |
|
Ciaphas posted:Trying to relearn WPF and MVVM, and binding is still confusing me a bit. I have an enum called Status in my view model, with possible values of READY and OPENING (and more later). Instead of those, I want to display pretty values in my application's status bar, like "Ready." and "Opening (45%)", for example. Is the way forward to bind a label to the enum normally, write a StatusValueConverter with the strings coded in, and set the label's converter to it? Or is there a better way? Use a property, maybe StatusLabel, that returns a string based on the value of the Status property in a case statement and your OpenProgress property. In the setter for Status, make a call to OnPropertyChanged for StatusLabel. GoodCleanFun fucked around with this message at 00:21 on Apr 23, 2015 |
# ? Apr 23, 2015 00:19 |
|
GoodCleanFun posted:Use a property, maybe StatusLabel, that returns a string based on the value of the Status property in a case statement and your OpenProgress property. In the setter for Status, make a call to OnPropertyChanged for StatusLabel. Bah, that's a lot easier . Here's me always bloody overthinking it. Thanks lots.
|
# ? Apr 23, 2015 00:32 |
|
A Prerelease of Sqlite for Windows 10 UAP apps is now out Now I can actually use all the nice database stuff I wrote in my Windows 10 apps without massive hacks.
|
# ? Apr 23, 2015 00:59 |
|
Looking at the visual tree showed me the ItemsPresenter was creating a StackPanel, which explained why the visible item was not being constrained so it would scroll properly. Setting ItemsPanelTemplate to use a Grid did the trick. Now I have the tab control still using MVVM with hundreds of visual elements per tab that preserves states between tab changes. Drastic Actions posted:A Prerelease of Sqlite for Windows 10 UAP apps is now out Inverness fucked around with this message at 01:39 on Apr 23, 2015 |
# ? Apr 23, 2015 01:21 |
|
Inverness posted:So what is the whole universal app thing and what is different about it compared to what we have now? Summary: You can now write a single project and have it run on multiple devices (before you had to have a different project for each device.) It's now easier to do form-factor-adaptive UIs too. I've been overseeing the technical side of things for .NET apps. I can't wait to say more about it all, but for that I have to wait until next Wednesday when things will be announced at Microsoft's Build conference. (We released a kind of intermediate "point-in-time" version of the tools last month, but I'd get too confused if I tried to describe that as well as the final way things work...)
|
# ? Apr 23, 2015 08:01 |
|
i'm looking forward to finding out the final details on 'plibs' or whatever they end up called, the replacement for pcls that work with .net core..
|
# ? Apr 23, 2015 08:33 |
|
ljw1004 posted:Summary: You can now write a single project and have it run on multiple devices (before you had to have a different project for each device.) It's now easier to do form-factor-adaptive UIs too. Unfortunately no one actually cares about windows phone or tablet so idk why they kept pushing universal apps so hard The cross platform stuff is way more useful
|
# ? Apr 23, 2015 11:16 |
|
I wish they'd just fix and improve WPF, and not reinvent the wheel over and over again. There is no viable alternative for desktop applications right now. WPF is powerful enough for any UI stuff you can think of, it just needs some overhauling in some places. Also, an updated cross-browser Silverlight would beat the hell out of the dumb Javascript hell everyone's using right now.
|
# ? Apr 23, 2015 13:13 |
|
amotea posted:I wish they'd just fix and improve WPF, and not reinvent the wheel over and over again. There is no viable alternative for desktop applications right now. It'd be nice if they were actually improving WPF, yes. As far as Silverlight, no one is going to install plugins to use your Web site (especially with mobile) and JavaScript has gotten a lot nicer to work with, IMO.
|
# ? Apr 23, 2015 13:32 |
|
RICHUNCLEPENNYBAGS posted:It'd be nice if they were actually improving WPF, yes. As far as Silverlight, no one is going to install plugins to use your Web site (especially with mobile) and JavaScript has gotten a lot nicer to work with, IMO. We have a large enterprise .NET/WPF application that resellers/customers would love to run in the browser (instead of continuously installing and updating clients all over the world). Installing a plug-in doesn't bother them. For regular websites with mass trafic I agree a plug-in doesn't really work. There are several 3rd party efforts to convert WPF into javascript though, so maybe if MSFT really wanted to they could make something like that work.
|
# ? Apr 23, 2015 13:42 |
|
Man, is it typical for the VS 2013 Community "web" installer to take like 4 hours to install the product? I was installing on 2012R2 VM with 4 gigs ram so resources shouldn't be an issue, and I've got a 50/50 pipe so it shouldn't have taken like 4 hours to download :|
|
# ? Apr 23, 2015 15:11 |
|
|
# ? Jun 6, 2024 23:35 |
|
I've seen downloads take that long simply because it's throttled on the senders side. Possibly what happened. The bane of my existence are those installers that are like 500Kb when the actual product is 6GB and you have to just sit there staring at an install screen in the center of the screen for 6 hours. UPDATE ON MY PERFORMANCE PROBLEM: Just wanted to drop this in here to mention you guys helped me out again. I used a profiler and found out almost 80% of my workload was in the properties of the object models. For example, one of my models is a wrapper around a List<T> and also a model with something like an Index field so, I had things like these: code:
It has reduced it from potentially taking an hour down to about 1-2 minutes for 300 items. I still have the potential that larger iterations can increase the time factorially(?is that a word?). I'm looking into parallelizing now the master items and also breaking item counts larger than say 150 items into groups as part of the optimization process to reduce the chances of an extreme situation. So... thanks everyone again. quick edit: My algorithm has to account for scoring every possible combination so 300 items means: 306,057,512,216,440,636,035,370,461,297,268,629,388,588,804,173,576,999,416,776,741,259,476,533,176,716,867,465,515,291,422,477,573,349,939,147,8 88,701,726,368,864,263,907,759,003,154,226,842,927,906,974,559,841,225,476,930,271,954,604,008,012,215,776,252,176,854,255,965,356,903,506,788,72 5,264,321,896,264,299,365,204,576,448,830,388,909,753,943,489,625,436,053,225,980,776,521,270,822,437,639,449,120,128,678,675,368,305,712,293,681 ,943,649,956,460,498,166,450,227,716,500,185,176,546,469,340,112,226,034,729,724,066,333,258,583,506,870,150,169,794,168,850,353,752,137,554,910, 289,126,407,157,154,830,282,284,937,952,636,580,145,235,233,156,936,482,233,436,799,254,594,095,276,820,608,062,232,812,387,383,880,817,049,600,0 00,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 possible scores. I cut that down drastically by breaking the recursive function if the combinations are more than 12 items and also by skipping items similar to the previous item checked. That should make the possibilities a lot less crashdome fucked around with this message at 17:22 on Apr 23, 2015 |
# ? Apr 23, 2015 17:11 |