Results 1 to 14 of 14

C++ Optimization

This is a discussion on C++ Optimization within the Off Topic forums, part of the Entertainment category; Before I post my code, is there anyone who is familiar with C++ enough to help me with optimization of ...
Page: 1


  1. #1
    Zxenke
    Guest

    Default

    Before I post my code, is there anyone who is familiar with C++ enough to help me with optimization of performance of a Windows utility program I wrote?

  2. #2
    Banned Senior Member
    Join Date
    Mar 2006
    Location
    Kanata eh?
    Posts
    7,163

    Default

    C++ is an evil... evil bitch

  3. #3
    Zxenke
    Guest

    Default

    very true, though it does have some advantages

  4. #4
    Zxenke
    Guest

    Default

    Points of interest:
    *****printf() vs cout vs ostream
    *****clock()

    Code:
    // Author: Erick Yeagle, Planet Development
    // Date: 11/21/2008
    // File: sw.cpp
    // Description: Utility that displays execution time of parameter commands
    // Version: 1.0
    //******Time properly displayed in format: [minute]m[seconds].[milliseconds]s
    //
    // Copyright (C) 2008, Erick Yeagle
    //******This program is free software. You can redistribute it and/or modify 
    //******it under the terms of the GNU Public License, as published by the Free 
    //******Software Foundation.
    //
    //******This program is distributed in the hope that it will be useful, but 
    //******WITHOUT ANY WARRANTY, and without the implied warranty of MERCHANTABILITY
    //******or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Public License for more
    //******details.
    //
    //******If you did not receive a copy of the GNU Public License along with this 
    //******program, please visit http://www.gnu.org/licenses
    
    #include <ctime>
    #include <string>
    using namespace std;
    
    int main(int argc, char* argv[]) {
    ****if (argc==1) {
    ********printf("%s %s %s\n\n%s%s%s\n%s\n**%s\n**%s\n", 
    ************"Syntax:", argv[0], "\"command\" [command_arguments]", 
    ************"Stopwatch (", argv[0], ".exe), version 1.0", 
    ************"Please refer any comments, concerns, or questions to:", 
    ************"E-mail:** [email protected]", 
    ************"Website:**http://PlanetDevelopment.no-ip.info");
    ********return 1;
    ****}
    ****string commands;
    ****for (int x(1); x<argc; x++) {
    ********commands+=argv[x];
    ********commands+=" ";
    ****}
    ****double start(clock());
    ****int success(system(commands.c_str()));
    ****double elapsed(clock()-start);
    ****if (success==0) printf("\n%i%s%.3f%s\n", 
    ********int(elapsed)/(60*CLOCKS_PER_SEC), "m", elapsed/CLOCKS_PER_SEC, "s");
    ****return 0;
    }

  5. #5
    Zaczaco11
    Guest

    Default

    erm bro i had bumped a topic in tech for about a month on CSS for websites (probably the easiest form of CSS) and no one even replied to it, you&#39;re not going to find help on here, especially in these forums. I&#39;d suggest http://gruntville.com/phpBB2/ my cousin is a part of those guys and they do coding for stanford and stuff, really intelligent people.

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    2,264

    Default

    How do you people understand how to do this stuff? I went on the website and looked at the tutorial and it looked pretty confusing. Is there classes to learn this stuff other then college courses?

  7. #7
    Legendary Mage Senior Member tHeUnBeAtAbLe's Avatar
    Join Date
    Dec 2007
    Posts
    4,981

    Default

    How do you people understand how to do this stuff? I went on the website and looked at the tutorial and it looked pretty confusing. Is there classes to learn this stuff other then college courses?[/b]
    it&#39;s pretty easy shit, except i left all the java and stuff cause i wasn&#39;t even going into programming, went into biomedical

  8. #8
    Zaczaco11
    Guest

    Default

    it&#39;s pretty easy shit, except i left all the java and stuff cause i wasn&#39;t even going into programming, went into biomedical [/b]
    then answer his question.

  9. #9
    Legendary Mage Senior Member tHeUnBeAtAbLe's Avatar
    Join Date
    Dec 2007
    Posts
    4,981

    Default

    then answer his question.[/b]
    I would if I continued taking the course, but I didn&#39;t, so only 2 years of learning it isn&#39;t enough I guess.

  10. #10
    evilwevel
    Guest

    Default

    never had C++; i can understand the basic stuff because we get lots of java, php, vb.net etc.

    but when i read your code i get confused :unsure:

  11. #11
    Speed
    Guest

    Default

    ive had C, and java and others but not C++ i was assumming it would be the same as C but.. no

    and yeah i get confused with ur code too lol

  12. #12
    Zxenke
    Guest

    Default

    Confusing how? Lol

    Granted it is written to take the least amount of time, so the verbose forms are not there.

  13. #13
    Speed
    Guest

    Default

    i get the basics of the code lol , its almost same as C

    main problem would be, i dont know what the hell that program does XD... or what do you want it to do haha

  14. #14
    Zxenke
    Guest

    Default

    Changed the printf to cout, since printf is solely C, and to keep with coding standard to not mix C and C++.

    The point of the program is to display the time of execution of whatever parameter commands given to it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •