Click here to Skip to main content
15,911,531 members
Home / Discussions / C#
   

C#

 
GeneralRe: Entity Framework Pin
Brendan Vogt18-Jun-08 3:55
Brendan Vogt18-Jun-08 3:55 
GeneralRe: Entity Framework Pin
Judah Gabriel Himango18-Jun-08 5:43
sponsorJudah Gabriel Himango18-Jun-08 5:43 
QuestionRe: Entity Framework Pin
Brendan Vogt23-Jun-08 3:42
Brendan Vogt23-Jun-08 3:42 
QuestionRetrieving Conrtols custom attribute?? Pin
zachbob17-Jun-08 4:07
zachbob17-Jun-08 4:07 
AnswerRe: Retrieving Conrtols custom attribute?? [modified] Pin
Henrik K. Larsen19-Jun-08 20:37
Henrik K. Larsen19-Jun-08 20:37 
Question[Message Deleted] Pin
imran_rafique17-Jun-08 3:41
imran_rafique17-Jun-08 3:41 
AnswerRe: WebBrowser Control objects Session issue? Pin
Christian Graus17-Jun-08 3:46
protectorChristian Graus17-Jun-08 3:46 
GeneralRe: WebBrowser Control objects Session issue? Pin
imran_rafique17-Jun-08 4:10
imran_rafique17-Jun-08 4:10 
GeneralRe: WebBrowser Control objects Session issue? Pin
Pete O'Hanlon17-Jun-08 4:55
mvePete O'Hanlon17-Jun-08 4:55 
Questionconvert long->p[][] Pin
cst_kvp17-Jun-08 2:02
cst_kvp17-Jun-08 2:02 
AnswerRe: convert long->p[][] Pin
Christian Graus17-Jun-08 2:02
protectorChristian Graus17-Jun-08 2:02 
GeneralRe: convert long->p[][] Pin
cst_kvp17-Jun-08 2:10
cst_kvp17-Jun-08 2:10 
GeneralRe: convert long->p[][] Pin
Christian Graus17-Jun-08 2:25
protectorChristian Graus17-Jun-08 2:25 
AnswerRe: convert long->p[][] Pin
Manoj Kumar Rai17-Jun-08 2:10
professionalManoj Kumar Rai17-Jun-08 2:10 
GeneralRe: convert long->p[][] Pin
cst_kvp17-Jun-08 2:13
cst_kvp17-Jun-08 2:13 
AnswerRe: convert long->p[][] Pin
Guffa17-Jun-08 3:11
Guffa17-Jun-08 3:11 
GeneralRe: convert long->p[][] Pin
Christian Graus17-Jun-08 3:24
protectorChristian Graus17-Jun-08 3:24 
QuestionCultureInfo.CurrentCulture Pin
George_George17-Jun-08 1:59
George_George17-Jun-08 1:59 
AnswerRe: CultureInfo.CurrentCulture Pin
carbon_golem17-Jun-08 2:04
carbon_golem17-Jun-08 2:04 
GeneralRe: CultureInfo.CurrentCulture Pin
George_George17-Jun-08 2:25
George_George17-Jun-08 2:25 
GeneralRe: CultureInfo.CurrentCulture Pin
Pete O'Hanlon17-Jun-08 3:20
mvePete O'Hanlon17-Jun-08 3:20 
GeneralRe: CultureInfo.CurrentCulture Pin
carbon_golem17-Jun-08 5:35
carbon_golem17-Jun-08 5:35 
I really wanted to give the answer that they would be the same, but after checking, I found some surprising results. Here is the timing code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Globalization;

namespace CultureInfoKata {
    class Program {
        static void Main(string[] args) {

            Stopwatch st = new Stopwatch();
            CultureInfo info = CultureInfo.CurrentCulture;
            Int64 iterations = 10000000;
            Int32 trials = 20;
            TimeSpan rAverage = TimeSpan.Zero;
            TimeSpan sAverage = TimeSpan.Zero;

            for (int j = 0; j < trials; j++) {
                Console.WriteLine("***************************************");
                Console.WriteLine("Starting iteration {0}", j.ToString());
                st.Start();
                for (int i = 0; i < iterations; i++) {
                    String.Format(info, "Text");
                }
                st.Stop();
                rAverage += st.Elapsed;
                Console.WriteLine(st.Elapsed.ToString());
                st.Reset();
                st.Start();
                for (int i = 0; i < iterations; i++) {
                    String.Format(CultureInfo.CurrentCulture, "Text");
                }
                st.Stop();
                sAverage += st.Elapsed;
                Console.WriteLine(st.Elapsed.ToString());
            }
            Console.WriteLine("***************************************");
            Console.WriteLine("Overall Results:");
            Console.WriteLine("Using object reference:{0}", TimeSpan.FromMilliseconds(rAverage.TotalMilliseconds / (Double)trials).ToString());
            Console.WriteLine("Using static reference:{0}", TimeSpan.FromMilliseconds(sAverage.TotalMilliseconds / (Double)trials).ToString());

            Console.ReadLine();
        }
    }
}


And here are the results:
***************************************
Starting iteration 0
00:00:02.4918791
00:00:02.6975864
***************************************
Starting iteration 1
00:00:05.1777309
00:00:02.7060980
***************************************
Starting iteration 2
00:00:05.1796692
00:00:02.6850936
***************************************
Starting iteration 3
00:00:05.1637124
00:00:02.6671581
***************************************
Starting iteration 4
00:00:05.1498686
00:00:02.7091927
***************************************
Starting iteration 5
00:00:05.2085886
00:00:02.7085847
***************************************
Starting iteration 6
00:00:05.1934733
00:00:02.7077047
***************************************
Starting iteration 7
00:00:05.2302492
00:00:02.7350313
***************************************
Starting iteration 8
00:00:05.2383390
00:00:02.8166922
***************************************
Starting iteration 9
00:00:05.3049657
00:00:02.6893061
***************************************
Starting iteration 10
00:00:05.1531035
00:00:02.6684418
***************************************
Starting iteration 11
00:00:05.1420193
00:00:02.6652652
***************************************
Starting iteration 12
00:00:05.1462953
00:00:02.6682994
***************************************
Starting iteration 13
00:00:05.1606059
00:00:02.7505680
***************************************
Starting iteration 14
00:00:05.4113100
00:00:02.7220753
***************************************
Starting iteration 15
00:00:05.2402528
00:00:02.7108708
***************************************
Starting iteration 16
00:00:05.2144905
00:00:02.7059263
***************************************
Starting iteration 17
00:00:05.1762065
00:00:02.6729379
***************************************
Starting iteration 18
00:00:05.1473431
00:00:02.7072361
***************************************
Starting iteration 19
00:00:05.2706150
00:00:02.8438043
***************************************
Overall Results:
Using object reference:00:00:05.0700000
Using static reference:00:00:02.7120000


I'm not sure how the results from trial 0 end up being different right off hand, I'd have to have a closer look. But it seems that using the static reference is generally faster in this test presuming I've not misused or taken for granted some aspect of the testing code. I'll run my profiler on it and get back with more results.

Scott P

“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra

GeneralRe: CultureInfo.CurrentCulture Pin
carbon_golem17-Jun-08 6:03
carbon_golem17-Jun-08 6:03 
GeneralRe: CultureInfo.CurrentCulture Pin
George_George17-Jun-08 21:19
George_George17-Jun-08 21:19 
QuestionHow can i do this? Pin
cristi_alonso17-Jun-08 1:53
cristi_alonso17-Jun-08 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.