Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. my code runs very slow with visual studio 2008 [modified]

my code runs very slow with visual studio 2008 [modified]

Scheduled Pinned Locked Moved C#
csharphelpvisual-studioquestioncode-review
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karayel_kara
    wrote on last edited by
    #1

    hi, friends i wrote a code in c#.net and it's ok. but i have a problem which is running slow i hope thare is some suggestions my code is folow static void calis(int rer, int dizin) { while (it < iterasyon && mmse <= 0.00001) { mmse = 0; mae = 0; for (int nf = 0; nf < orneksay; nf++) { mmse += hesaplas(ndata, nf); trains(nf); }//nf mmse = 0.5 * (mmse / (orneksay * nron)); if (it % 100 == 0) { yazs.WriteLine(mmse.ToString()); yazs.Flush(); } it++; }//it dosyas.Close(); yazss.WriteLine(rer.ToString() + " " + mmse.ToString() + " " + it.ToString()); yazss.Flush(); dosyass.Close(); } } i call calis function and i see cpu usage %25 mey it improve its performs ? can you help me? regads.

    modified on Thursday, April 1, 2010 2:53 AM

    L S 2 Replies Last reply
    0
    • K karayel_kara

      hi, friends i wrote a code in c#.net and it's ok. but i have a problem which is running slow i hope thare is some suggestions my code is folow static void calis(int rer, int dizin) { while (it < iterasyon && mmse <= 0.00001) { mmse = 0; mae = 0; for (int nf = 0; nf < orneksay; nf++) { mmse += hesaplas(ndata, nf); trains(nf); }//nf mmse = 0.5 * (mmse / (orneksay * nron)); if (it % 100 == 0) { yazs.WriteLine(mmse.ToString()); yazs.Flush(); } it++; }//it dosyas.Close(); yazss.WriteLine(rer.ToString() + " " + mmse.ToString() + " " + it.ToString()); yazss.Flush(); dosyass.Close(); } } i call calis function and i see cpu usage %25 mey it improve its performs ? can you help me? regads.

      modified on Thursday, April 1, 2010 2:53 AM

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Please edit your original post, add PRE tags around the code so it gets all formatted and readable, and check some of it, I don't think while (it < iterasyon mmse <= 0.00001) could ever compile. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      Getting an article published on CodeProject should be easier and faster.


      1 Reply Last reply
      0
      • K karayel_kara

        hi, friends i wrote a code in c#.net and it's ok. but i have a problem which is running slow i hope thare is some suggestions my code is folow static void calis(int rer, int dizin) { while (it < iterasyon && mmse <= 0.00001) { mmse = 0; mae = 0; for (int nf = 0; nf < orneksay; nf++) { mmse += hesaplas(ndata, nf); trains(nf); }//nf mmse = 0.5 * (mmse / (orneksay * nron)); if (it % 100 == 0) { yazs.WriteLine(mmse.ToString()); yazs.Flush(); } it++; }//it dosyas.Close(); yazss.WriteLine(rer.ToString() + " " + mmse.ToString() + " " + it.ToString()); yazss.Flush(); dosyass.Close(); } } i call calis function and i see cpu usage %25 mey it improve its performs ? can you help me? regads.

        modified on Thursday, April 1, 2010 2:53 AM

        S Offline
        S Offline
        Som Shekhar
        wrote on last edited by
        #3

        Your code is very confusing. As Luc suggested, I wonder if it would compile.

        karayel_kara wrote:

        while (it < iterasyon && mmse <= 0.00001) { mmse = 0; mae = 0; for (int nf = 0; nf < orneksay; nf++) { mmse += hesaplas(ndata, nf); trains(nf); }//nf

        I see the delay happening in this block. But we cannot help you till the time we don't know the initial value of mmse and what does hesaplas(ndata, nf) do? Also, what is the value of orneksay? There are so many loopholes here. Suggestion: Add two int counters. one in while loop and one in for loop just to notice how many times does this loop run. If this number is too high, you should probably consider ways to reduce them.

        K 1 Reply Last reply
        0
        • S Som Shekhar

          Your code is very confusing. As Luc suggested, I wonder if it would compile.

          karayel_kara wrote:

          while (it < iterasyon && mmse <= 0.00001) { mmse = 0; mae = 0; for (int nf = 0; nf < orneksay; nf++) { mmse += hesaplas(ndata, nf); trains(nf); }//nf

          I see the delay happening in this block. But we cannot help you till the time we don't know the initial value of mmse and what does hesaplas(ndata, nf) do? Also, what is the value of orneksay? There are so many loopholes here. Suggestion: Add two int counters. one in while loop and one in for loop just to notice how many times does this loop run. If this number is too high, you should probably consider ways to reduce them.

          K Offline
          K Offline
          karayel_kara
          wrote on last edited by
          #4

          thanks for reply. i take notice of a point, when i look at cpu using, i observer my code is using cpu %25 and i have quad pc so i can't use %75 of my cpu performance is there this problem solution ? not: orneksay=dataset

          S 1 Reply Last reply
          0
          • K karayel_kara

            thanks for reply. i take notice of a point, when i look at cpu using, i observer my code is using cpu %25 and i have quad pc so i can't use %75 of my cpu performance is there this problem solution ? not: orneksay=dataset

            S Offline
            S Offline
            Som Shekhar
            wrote on last edited by
            #5

            No buddy... it is not. You are working on a single thread and it will try to squeeze as much time of processor as it can. I wouldn't suggest trying multithreading till the time you haven't sorted number of loops. I have a feeling that its just number of loops. Could you do that counter and tell us how many times while loop runs and how many times for loop runs?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups