The Big Programming Thread - Page 166
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
![]()
tofucake
Hyrule18982 Posts
| ||
Craton
United States17234 Posts
| ||
billy5000
United States865 Posts
| ||
SiPa
Germany129 Posts
+ Show Spoiler + I'm working a c++ Project with Microsoft Visual Studio 2010. I want to use System::Diagnostics::Stopwatch(http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx). What do I have to include/change in my project to use that? Any properties? It doesnt know "System" :S It's .Net, but I've successfully included ppl. (.net library)... Edit: Let me rephrase that (and nvm the above part): I need to compare 2 Programs on how long they take. For that, any processes/threads running in the background should be taken into consideration, meaning no matter how many threads run in the background, the 2 programs (and their time taken til completion) should be comparable. Any suggestions, or what words i should google/what frameworks to use? (CPU time? processing time?) Edit2:http://evilzone.org/code-library/%28c%29-timing-cpu-usage/ Edit3: I hope some1 will still read this! I tried the link in Edit2, but it looks like it's not working the way I want. I want it to display the same time, no matter how busy the CPU is when i execute my program. (Meaning: only Program and Windows are running, program outputs: "i took 2 seconds". Program and Windows and a Hundred other Programs are running, program outputs: "i took 2 seconds".) | ||
Glowbox
Netherlands330 Posts
| ||
heishe
Germany2284 Posts
| ||
SiPa
Germany129 Posts
On September 12 2012 22:09 SiPa wrote: Havent done a question in a while... well here it goes: + Show Spoiler + I'm working a c++ Project with Microsoft Visual Studio 2010. I want to use System::Diagnostics::Stopwatch(http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx). What do I have to include/change in my project to use that? Any properties? It doesnt know "System" :S It's .Net, but I've successfully included ppl. (.net library)... Edit: Let me rephrase that (and nvm the above part): I need to compare 2 Programs on how long they take. For that, any processes/threads running in the background should be taken into consideration, meaning no matter how many threads run in the background, the 2 programs (and their time taken til completion) should be comparable. Any suggestions, or what words i should google/what frameworks to use? (CPU time? processing time?) Edit2:http://evilzone.org/code-library/%28c%29-timing-cpu-usage/ Edit3: I hope someone will still read this! I tried the link in Edit2, but it looks like it's not working the way I want. I want it to display the same time, no matter how busy the CPU is when i execute my program. (Meaning: only program and windows are running, program outputs: "i took 2 seconds". Program and Windows and a hundred other programs are running, program outputs: "i took 2 seconds".) Kinda need to bump this, since I havent found an answer yet. | ||
darmousseh
United States3437 Posts
| ||
tec27
United States3690 Posts
On September 13 2012 17:11 darmousseh wrote: Have any of you guys started using NodeJs yet? It looks really exciting. Coming from the ruby on rails world, nodejs looks to me like it's the next Big Thing in the web developer world. What are your guy's thoughts? I use it for basically everything that I can. I really enjoy it, but I don't think its for everyone. I also don't know that its really the 'Next Big Thing'. The nice thing about node is that the core libraries are kept really small and clean, so you can keep really fine-grained control over what you're using and how you're using it. Can't really say the same for Rails, which has become pretty bloated and large at this point. Node's like this weird mix of low-level programming with a high level language. Seems really strange, but I really love using it. PS: Not sure how in-depth you've gotten into node, but if you ever need something to listen to, the NodeUp podcast is quite excellent and educational to boot!: http://nodeup.com/ | ||
heishe
Germany2284 Posts
On September 13 2012 16:41 SiPa wrote: Kinda need to bump this, since I havent found an answer yet. Have you read what I wrote? Just use the stuff in std::chrono (cplusplus.com as a reference) and measure the time manually in each thread. edit: Of course, this only works if you're not using C++/CLI. | ||
SiPa
Germany129 Posts
I've tried chrono now. Empty project in Visual Studio 2010 --> Included the Inlcude-Folder from Visual Studio 2012 (since there was a chrono in there) --> tried to use chrono --> compiler errors. Compiled it with Visual Studio 2012 now, lets see if it does what I want it to do... Edit: Just tested. Worked just as good as ctime (clock_t) meaning it didnt do, what I wanted it to do, meaning the time (or whatever elapsed.count() returns) differs, depending on how many instances of this program are running at one time. Also I've tried Steady_clock, system_clock and highres_clock | ||
heishe
Germany2284 Posts
But now I don't understand what you want to do. Why don't you just print " I took 2 seconds" then? ![]() Or are you having the program that one instance needs longer than the other? | ||
Deleted User 101379
4849 Posts
On September 13 2012 21:03 SiPa wrote: Ok nvm the PMs. I've tried chrono now. Empty project in Visual Studio 2010 --> Included the Inlcude-Folder from Visual Studio 2012 (since there was a chrono in there) --> tried to use chrono --> compiler errors. Compiled it with Visual Studio 2012 now, lets see if it does what I want it to do... Edit: Just tested. Worked just as good as ctime (clock_t) meaning it didnt do, what I wanted it to do, meaning the time (or whatever elapsed.count() returns) differs, depending on how many instances of this program are running at one time. Also I've tried Steady_clock, system_clock and highres_clock So what you want is the actual time the CPU worked on this instance of your program, not the time it was running in total? I only know how to do that on Linux in a non-portable way, so i googled it for windows and found this: http://nadeausoftware.com/articles/2012/03/c_c_tip_how_measure_cpu_time_benchmarking which pointed me to http://msdn.microsoft.com/en-us/library/windows/desktop/ms683223(v=vs.85).aspx I don't know if that does the job but it sounds more like it. | ||
SiPa
Germany129 Posts
http://www.philosophicalgeek.com/2009/01/03/determine-cpu-usage-of-current-process-c-and-c/ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683223(v=vs.85).aspx http://nadeausoftware.com/articles/2012/03/c_c_tip_how_measure_cpu_time_benchmarking tomorrow. Will tell you more by then. Thx for answers! | ||
SiPa
Germany129 Posts
atm i'm getting Zeros in lpExitTime, whenever I call GetThreadTimes. I guess it's because the thread specified with HANDLE self; self = GetCurrentThread(); has not ended yet. How do I get a thread to end thou? Have tried the same with GetProcessTimes and got the same result. Fyi: I'm parallelizing some stuff and have alot of loops. If I want the Threads used in a Loop, where do I have to put the self=GetCurrentThread() or =GetCurrentProcess() to represent the loop-thread/process? | ||
Andin
United States6 Posts
Personally, if it sounds good and doesn't have lyrics I'll play it. The general trend for me is something electronic. Albums/Artists I've been writing to recently: >> Tron: Legacy soundtrack >> Kavinsky (all of his work) >> Ocean's 13 soundtrack >> Portal 2 soundtrack >> Team Fortress 2 menu music >> Explosions in the Sky And for you Doctor Who fans, forty minutes of sweet epicness. | ||
heishe
Germany2284 Posts
On September 14 2012 19:07 SiPa wrote: Ok. So far I've tried GetCurrentProcess and GetCurrentThread with little results. (http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms683237(v=vs.85).aspx) atm i'm getting Zeros in lpExitTime, whenever I call GetThreadTimes. I guess it's because the thread specified with HANDLE self; self = GetCurrentThread(); has not ended yet. How do I get a thread to end thou? Have tried the same with GetProcessTimes and got the same result. Fyi: I'm parallelizing some stuff and have alot of loops. If I want the Threads used in a Loop, where do I have to put the self=GetCurrentThread() or =GetCurrentProcess() to represent the loop-thread/process? You could try explaining why you need to do the thing you want to do. Maybe there's another way than to use the scheduled time that the process gets (I can't think of anything where you might need that). | ||
SiPa
Germany129 Posts
This time should never change, no matter how many other programs i execute at the same time. I might have already mentioned, that I will try/am trying to use System::Diagnostics::Stopwatch. Wish me luck | ||
![]()
tofucake
Hyrule18982 Posts
On September 14 2012 21:35 Andin wrote: What music do you guys like to listen to when you code? Personally, if it sounds good and doesn't have lyrics I'll play it. The general trend for me is something electronic. Albums/Artists I've been writing to recently: >> Tron: Legacy soundtrack >> Kavinsky (all of his work) >> Ocean's 13 soundtrack >> Portal 2 soundtrack >> Team Fortress 2 menu music >> Explosions in the Sky And for you Doctor Who fans, forty minutes of sweet epicness. I run a pandora station comprised of Electronica, Classic Rock, occasional Dubstep. | ||
phar
United States1080 Posts
On September 13 2012 17:11 darmousseh wrote: Have any of you guys started using NodeJs yet? It looks really exciting. Coming from the ruby on rails world, nodejs looks to me like it's the next Big Thing in the web developer world. What are your guy's thoughts? If you are looking to write server or backend code, I strongly suggest you use something that is more scalable, and offers better concurrency and performance than NodeJs. While I can appreciate the need for javascript on the frontend, using it elsewhere does not seem like a good idea. If you want to use something new and shiny, I suppose you could take a look at Go. There'll be a bit of a learning curve to get used to the syntax & style if you're coming from a js/RoR background, but it'd be worth it in the end. NodeJs will certainly be easier for you if you're used to ruby on rails, so if you're just messing around with personal projects, it'll work just fine. On September 14 2012 21:35 Andin wrote:What music do you guys like to listen to when you code? When I'm doing something that actually requires design and thought? Nothing. When I'm cranking out code or tests that I've already got "finished" in my head, or going through debugging? Anything from Stravinsky to Brother Ali. Now that you mention it, Pandora has apparently bugged out on me and is playing A Tribe Called Quest followed by Cut Chemist at the same time as Liszt. It sounds... not good. | ||
| ||