{21,30,33,36,39,44,48}, {56,27,36,40,41,42,46}, {101,6,7,15,17,18,21}, {132,25,26,31,40,41,44}, {0,0,0,0}, {3,2116,46,1}, {4,3106,91,2}, {5,4052,135,3} , {6,4955,178,4}, {7,5816,220,5}, {8,6666, 261,6}, {9,7416,301,7}, {10,8157,340,8}, { 11,8860,378,9}}, {12,9526,415,10}, {13,10156,451,11}, {14,1,10751,486,12}, {15,11312,520,13}, {16,11840,553,14}, {17,12336,585,15}, {18,12801,616,16 }, {19,13236,646,17}, {20,16442,675,18}, {21,14020 ,703,19}, {22,14371,730,20}, {23,14696,756,21}, {24,14996,781,22}, {25,15272,805,23}, {26,15525,828,24}, {27,15756,850,25}, {28,15966,871,26}, {29,16156,891,27}, {30,16327,910,28}, {31,16480,928,29}, {32,16616,945 ,30}, {33,16736,961,31}, {34,16841,976,32}, {35 ,16932,990,33}, {36,17010,1003,34}, {37,17076,1015,35}, {39,17176,1036,37}, {40,17212,1045,38}, {41,17240,1053,39}, {42,17261,1060,40}, {43,47276,1066,41 }, {44,17286,1071,42}, {45,17292,1075,43}, {46,17295,1078,44}, {47,17296,1080,45}, {48,0,1081,46}, {49,0,0,47}}; } class CWeekTime {public static int WeekTime() for(int s1 = 1 ; s1 对于(int s2 = s1 + 1; s2< = 5; s2 ++) { for(int s3 = s2 + 1; s3< = 6; s3 ++) GlobalValues.gnSumSeconds = GlobalValues.gaSeconds [GlobalValues.gaWorkDays [s1], 1] + GlobalValues.gaSeconds [GlobalValues.gaWorkDays [s2],2] + GlobalValues.gaSeconds [GlobalValues.gaWorkDays [s3],3]; GlobalValues.gaSumWorkDays [GlobalValues.gnSumSeconds] = 1; } } } return (0); } } class CVerifyMissingTime { public static int VerifyMissingTime() { int lnSumMissingTime=0; for (int xxxLoop=1 ; xxxLoop<=10; xxxLoop++) { lnSumMissingTime=0; for (int lp1=1 ; lp1<=GlobalValues.kNoWeeks-5 ; lp1++) { for (int lp2=lp1+1 ; lp2<=GlobalValues.kNoWeeks-4 ; lp2++) { for (int lp3=lp2+1 ; lp3<=GlobalValues. kNoWeeks- 3 ; lp3++) { for (int lp4=lp3+1 ; lp4<=GlobalValues.kNoWeeks-2 ; lp4++) { for (int lp5=lp4+1 ; lp5<=GlobalValues.kNoWeeks-1 ; lp5++) { for (int lp6=lp5+1 ; lp6<=GlobalValues.kNoWeeks ; lp6++) { if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp3,3]]>0) { lp6=lp5=lp4=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp4,3]]>0) { lp6=lp5=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp4,3]]>0) { lp6=lp5=100; continue; } if (GlobalValues.gaSumWorkDays[ GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp4,3]]>0) { lp6=lp5=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=1 00; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp3,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp 6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp3,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp3,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp4,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } lnSumMissingTime++; } } } } } } } Console.WriteLine("Missing Time {0}",lnSumMissingTime); return lnSumMissingTime; } } TIA Roy Hi, I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than C++? What am I doing wrong? Here is my code: using System; class cMain { public static int Main() { int[,] TimeSchedule = new int[GlobalValues.kNoDays+1,7] { { 0, 0, 0, 0, 0, 0, 0}, { 1, 1, 2, 3, 4, 5,49}, { 2, 23,27,36,38,45,47}, { 3, 23,33,35,42,44,48}, { 4, 24,29,35,39,40,46}, { 5, 22,28,34,40,44,45}, { 6, 1, 2, 6,11,17,20}, { 7, 1, 2, 7,10,16,21}, { 8, 1, 2, 8,13,15,18}, { 9, 23,26,34,36,41,47}, { 10, 1, 2, 9,12,14,19}, { 11, 23,28,31,35,37,42}, { 12, 25,34,37,40,45,48}, { 13, 32,33,44,46,47,48}, { 14, 24,25,26,27,37,48}, { 15, 24,29,30,32,40,42}, { 16, 1, 3, 6,10,15,19}, { 17, 1, 3, 7,11,14,18}, { 18, 22,23,25,35,42,43}, { 19, 1, 3, 8,12,17,21}, { 20, 31,33,34,40,43,45}, { 21, 30,33,36,39,44,48}, { 22, 25,29,37,38,41,48}, { 23, 1, 3, 9,13,16,20}, { 24, 1, 4, 6,13,14,21}, { 25, 24,25,28,33,41,45}, { 26, 22,26,31,38,40,48}, { 27, 1, 4, 7,12,15,20}, { 28, 24,26,27,31,33,43}, { 29, 23,27,32,39,40,41}, { 30, 1, 4, 8,11,16,19}, { 31, 22,25,32,43,46,47}, { 32, 22,33,37,39,42,47}, { 33, 1, 4, 9,10,17,18}, { 34, 27,35,38,39,45,46}, { 35, 1, 5, 6,12,16,18}, { 36, 1, 5, 7,13,17,19}, { 37, 1, 5, 8,10,14,20}, { 38, 1, 5, 9,11,15,21}, { 39, 1, 6, 7, 8, 9,49}, { 40, 26,29,36,42,45,46}, { 41, 1,10,11,12,13,49}, { 42, 1,14,15,16,17,49}, { 43, 1,18,19,20,21,49}, { 44, 28,31,32,37,46,47}, { 45, 22,25,30,36,39,43}, { 46, 24,37,41,43,44,45}, { 47, 26,34,35,39,41,46}, { 48, 27,30,32,38,42,45}, { 49, 22,24,26,27,28,44}, { 50, 23,24,32,34,38,39}, { 51, 22,32,33,35,36,37}, { 52, 22,28,29,38,41,44}, { 53, 28,39,42,43,47,48}, { 54, 27,30,35,40,41,47}, { 55, 2, 3, 6, 7,12,13}, { 56, 27,36,40,41,42,46}, { 57, 2, 3, 8, 9,10,11}, { 58, 28,30,31,36,37,39}, { 59, 2, 3,14,15,20,21}, { 60, 23,24,29,36,40,47}, { 61, 29,31,33,38,41,43}, { 62, 2, 3,16,17,18,19}, { 63, 26,29,30,35,45,47}, { 64, 22,25,27,29,34,43}, { 65, 2, 4, 6, 9,15,16}, { 66, 26,37,38,40,43,44}, { 67, 26,30,32,34,41,42}, { 68, 23,30,31,33,43,46}, { 69, 25,31,35,39,44,47}, { 70, 2, 4, 7, 8,14,17}, { 71, 2, 4,10,13,19,20}, { 72, 2, 4,11,12,18,21}, { 73, 24,34,36,38,42,46}, { 74, 2, 5, 6, 8,19,21}, { 75, 2, 5, 7, 9,18,20}, { 76, 22,24,31,41,45,48}, { 77, 25,26,28,33,38,40}, { 78, 2, 5,10,12,15,17}, { 79, 2, 5,11,13,14,16}, { 80, 2, 6,10,14,18,49}, { 81, 2, 7,11,15,19,49}, { 82, 2, 8,12,16,20,49}, { 83, 2, 9,13,17,21,49}, { 84, 23,26,29,32,39,45}, { 85, 24,30,34,35,38,47}, { 86, 3, 4, 6, 8,18,20}, { 87, 3, 4, 7, 9,19,21}, { 88, 3, 4,10,12,14,16}, { 89, 3, 4,11,13,15,17}, { 90, 3, 5, 6, 9,14,17}, { 91, 3, 5, 7, 8,15,16}, { 92, 27,28,29,31,34,37}, { 93, 23,25,30,37,46,48}, { 94, 3, 5,10,13,18,21}, { 95, 3, 5,11,12,19,20}, { 96, 3, 6,11,16,21,49}, { 97, 3, 7,10,17,20,49}, { 98, 6, 7,14,16,19,20}, { 99, 3, 8,13,14,19,49}, {100, 3, 9,12,15,18,49}, {101, 6, 7,15,17,18,21}, {102, 6, 8,10,13,16,17}, {103, 6, 8,11,12,14,15}, {104, 6, 9,10,12,20,21}, {105, 6, 9,11,13,18,19}, {106, 25,31,32,35,36,44}, {107, 4, 5, 8, 9,12,13}, {108, 4, 5,14,15,18,19}, {109, 4, 5,16,17,20,21}, {110, 4, 6,12,17,19,49}, {111, 4, 7,13,16,18,49}, {112, 7, 8,10,12,18,19}, {113, 7, 8,11,13,20,21}, {114, 7, 9,10,13,14,15}, {115, 7, 9,11,12,16,17}, {116, 8, 9,14,16,18,21}, {117, 8, 9,15,17,19,20}, {118, 10,11,14,17,19,21}, {119, 10,11,15,16,18,20}, {120, 12,13,14,17,18,20}, {121, 12,13,15,16,19,21}, {122, 4, 8,10,15,21,49}, {123, 4, 9,11,14,20,49}, {124, 5, 6,13,15,20,49}, {125, 5, 7,12,14,21,49}, {126, 5, 8,11,17,18,49}, {127, 5, 9,10,16,19,49}, {128, 4, 5, 6, 7,10,11}, {129, 22,23,28,30,44,46}, {130, 27,29,33,34,44,48}, {131, 28,32,36,42,43,48}, {132, 25,26,31,40,41,44}, {133, 24,28,38,40,43,48}, {134, 28,35,36,43,47,48}, {135, 24,25,31,38,44,45}, {136, 26,28,41,43,45,48}, {137, 25,28,29,33,44,46}, {138, 27,30,31,37,43,44}, {139, 22,23,25,31,34,48}, {140, 23,25,27,28,33,37}, {141, 22,29,30,31,33,48}, {142, 22,34,37,43,44,46}, {143, 25,31,36,42,44,47}, {144, 38,39,40,41,42,47}, {145, 22,26,33,37,38,45}, {146, 24,27,34,39,42,47}, {147, 23,26,32,35,42,45}, {148, 28,32,35,39,43,48}, {149, 23,29,37,43,44,48}, {150, 22,27,28,31,46,48}, {151, 22,24,33,37,40,41}, {152, 25,28,30,33,34,43}, {153, 23,30,34,38,40,46}, {154, 26,30,32,36,39,45}, {155, 27,29,34,35,38,41}, {156, 26,29,32,45,46,47}, {157, 23,24,27,30,41,46}, {158, 23,29,30,36,39,42}, {159, 25,31,32,39,42,44}, {160, 24,32,35,36,38,41}, {161, 24,26,27,29,40,45}, {162, 27,32,34,35,36,40}, {163, 23,30,35,36,46,47}}; for (int lpcnt=1; lpcnt<=GlobalValues.kNoSeconds; lpcnt++) GlobalValues.gaSumWorkDays[lpcnt]=0; for (int mm=1 ; mm<=GlobalValues.kNoDays ; mm++) { GlobalValues.gaWorkDays[1]=TimeSchedule[mm,1]; GlobalValues.gaWorkDays[2]=TimeSchedule[mm,2]; GlobalValues.gaWorkDays[3]=TimeSchedule[mm,3]; GlobalValues.gaWorkDays[4]=TimeSchedule[mm,4]; GlobalValues.gaWorkDays[5]=TimeSchedule[mm,5]; GlobalValues.gaWorkDays[6]=TimeSchedule[mm,6]; CWeekTime.WeekTime(); } int lnTotMissingTime=0; int t = DateTime.Now.Minute*60+DateTime.Now.Second; Console.WriteLine("TimeStarted "+t); lnTotMissingTime=CVerifyMissingTime.VerifyMissingT ime(); Console.WriteLine("Total No of Missing Time {0} ",lnTotMissingTime); t = DateTime.Now.Minute*60+DateTime.Now.Second; Console.WriteLine("Time Ended "+t); Console.ReadLine(); return 0; } } public class GlobalValues { public const int kNoWeeks=49; public const int kNoDays=163; public const int kNoSeconds=18424; public static int gnSumSeconds = 0; public static int[] gaWorkDays= new int [7]; public static int[] gaSumWorkDays = new int[kNoSeconds+1]; public static int[,] gaSeconds = new int [kNoWeeks+1,4] { {0, 0, 0, 0}, {1, 0, 0, 0}, {2, 1081, 0, 0}, {3, 2116, 46, 1}, {4, 3106, 91, 2}, {5, 4052, 135, 3}, {6, 4955, 178, 4}, {7, 5816, 220, 5}, {8, 6636, 261, 6}, {9, 7416, 301, 7}, {10, 8157, 340, 8}, {11, 8860, 378, 9}, {12, 9526, 415, 10}, {13, 10156, 451, 11}, {14, 10751, 486, 12}, {15, 11312, 520, 13}, {16, 11840, 553, 14}, {17, 12336, 585, 15}, {18, 12801, 616, 16}, {19, 13236, 646, 17}, {20, 13642, 675, 18}, {21, 14020, 703, 19}, {22, 14371, 730, 20}, {23, 14696, 756, 21}, {24, 14996, 781, 22}, {25, 15272, 805, 23}, {26, 15525, 828, 24}, {27, 15756, 850, 25}, {28, 15966, 871, 26}, {29, 16156, 891, 27}, {30, 16327, 910, 28}, {31, 16480, 928, 29}, {32, 16616, 945, 30}, {33, 16736, 961, 31}, {34, 16841, 976, 32}, {35, 16932, 990, 33}, {36, 17010, 1003, 34}, {37, 17076, 1015, 35}, {38, 17131, 1026, 36}, {39, 17176, 1036, 37}, {40, 17212, 1045, 38}, {41, 17240, 1053, 39}, {42, 17261, 1060, 40}, {43, 17276, 1066, 41}, {44, 17286, 1071, 42}, {45, 17292, 1075, 43}, {46, 17295, 1078, 44}, {47, 17296, 1080, 45}, {48, 0, 1081, 46}, {49, 0, 0, 47}}; } class CWeekTime { public static int WeekTime() { for (int s1=1 ; s1<=4 ; s1++) { for (int s2=s1+1 ; s2<=5 ; s2++) { for (int s3=s2+1 ; s3<=6 ; s3++) { GlobalValues.gnSumSeconds=GlobalValues.gaSeconds[GlobalValues.gaWorkDays[s1],1]+GlobalValues.gaSeconds[GlobalValues.gaWorkDays[s2],2]+GlobalValues.gaSeconds[GlobalValues.gaWorkDays[s3],3]; GlobalValues.gaSumWorkDays[GlobalValues.gnSumSeconds]=1; } } } return (0); } } class CVerifyMissingTime { public static int VerifyMissingTime() { int lnSumMissingTime=0; for (int xxxLoop=1 ; xxxLoop<=10; xxxLoop++) { lnSumMissingTime=0; for (int lp1=1 ; lp1<=GlobalValues.kNoWeeks-5 ; lp1++) { for (int lp2=lp1+1 ; lp2<=GlobalValues.kNoWeeks-4 ; lp2++) { for (int lp3=lp2+1 ; lp3<=GlobalValues.kNoWeeks-3 ; lp3++) { for (int lp4=lp3+1 ; lp4<=GlobalValues.kNoWeeks-2 ; lp4++) { for (int lp5=lp4+1 ; lp5<=GlobalValues.kNoWeeks-1 ; lp5++) { for (int lp6=lp5+1 ; lp6<=GlobalValues.kNoWeeks ; lp6++) { if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp3,3]]>0) { lp6=lp5=lp4=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp4,3]]>0) { lp6=lp5=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp4,3]]>0) { lp6=lp5=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp4,3]]>0) { lp6=lp5=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp3,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp5,3]]>0) { lp6=100; continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp2,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp1,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp3,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp2,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp3,1]+GlobalValues.gaSeconds[lp4,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp3,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } if (GlobalValues.gaSumWorkDays[GlobalValues.gaSeconds[lp4,1]+GlobalValues.gaSeconds[lp5,2]+GlobalValues.gaSeconds[lp6,3]]>0) { continue; } lnSumMissingTime++; } } } } } } } Console.WriteLine("Missing Time {0}",lnSumMissingTime); return lnSumMissingTime; } } TIA RoyHi, Basically, for all intensive purposes all I have is 2 arrays (gaSeconds & TimeSchedule). The array gaSeconds as you can see, has to be accessed many, many times and for this application, it cannot absolutely be a jagged array. The values in the gaSeconds in the real application change, but I kept them constant for the sake of simplicity, so although it looks that I am aimlessly accessing the same information many times in the CVerifyMissingTime, I am not. All I wanted to know if there is a way to make this faster. I am not that worried about wheter it is in classic object oriented programming form as speed is of the essence. So basically this is the program in a more intuitive way: I have to create 2 arrays (that can be seen throughout the whole program) and one of which will be accessed many times. Thanks Roy "Jon Skeet [C# MVP]" < SK *** @ pobox.com> wrote in message news:MP***********************@msnews.microsoft.co m...Hi,Basically, for all intensive purposes all I have is 2 arrays (gaSeconds &TimeSchedule). The array gaSeconds as you can see, has to be accessed many,many times and for this application, it cannot absolutely be a jagged array.The values in the gaSeconds in the real application change, but I kept themconstant for the sake of simplicity, so although it looks that I amaimlessly accessing the same information many times in theCVerifyMissingTime, I am not.All I wanted to know if there is a way to make this faster. I am not thatworried about wheter it is in classic object oriented programming form asspeed is of the essence.So basically this is the program in a more intuitive way:I have to create 2 arrays (that can be seen throughout the whole program)and one of which will be accessed many times.ThanksRoy"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in messagenews:MP***********************@msnews.microsoft.co m... Roy Gourgi <ro***@videotron.ca> wrote: Roy Gourgi <ro***@videotron.ca> wrote: I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than C++? What am I doing wrong? I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than C++? What am I doing wrong? Well, you haven’’t shown your C++ code, you haven’’t said what the program is meant to be doing, and the code is frighteningly difficult to understand (partly due to not being object-oriented at all, as far as I can see), which doesn’’t really help. I would start by refactoring it into a much easier to understand form, and *then* look at the efficiency of it. You could also try using jagged arrays instead of rectangular ones - that’’s more efficient in .NET, and as the majority of your time seems to be spent in that rather large set of if statements which do very little other than array access, that could make a significant difference. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too Well, you haven''t shown your C++ code, you haven''t said what the program is meant to be doing, and the code is frighteningly difficult to understand (partly due to not being object-oriented at all, as far as I can see), which doesn''t really help. I would start by refactoring it into a much easier to understand form, and *then* look at the efficiency of it. You could also try using jagged arrays instead of rectangular ones - that''s more efficient in .NET, and as the majority of your time seems to be spent in that rather large set of if statements which do very little other than array access, that could make a significant difference. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too 这篇关于为什么我的Time算法如此慢 - 有谁能告诉我为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 14:43