Click here to Skip to main content
15,909,827 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: postfix increment and decrement can get bent Pin
F-ES Sitecore4-Dec-19 2:55
professionalF-ES Sitecore4-Dec-19 2:55 
GeneralRe: postfix increment and decrement can get bent Pin
harold aptroot3-Dec-19 23:33
harold aptroot3-Dec-19 23:33 
GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch3-Dec-19 23:34
mvahoney the codewitch3-Dec-19 23:34 
GeneralRe: postfix increment and decrement can get bent Pin
Daniel Pfeffer3-Dec-19 23:37
professionalDaniel Pfeffer3-Dec-19 23:37 
GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch3-Dec-19 23:38
mvahoney the codewitch3-Dec-19 23:38 
GeneralRe: postfix increment and decrement can get bent Pin
W Balboos, GHB4-Dec-19 0:57
W Balboos, GHB4-Dec-19 0:57 
GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch4-Dec-19 1:17
mvahoney the codewitch4-Dec-19 1:17 
GeneralRe: postfix increment and decrement can get bent Pin
dan!sh 4-Dec-19 2:11
professional dan!sh 4-Dec-19 2:11 
honey the codewitch wrote:
is ++<target> really so much worse that <target>++?


No. Based on my super intense all conclusive test, they are same. Here is the test. I hope you can understand this complex set up.
static void Main(string[] args)
{
    List<double> preIncrement = new List<double>();
    List<double> postIncrement = new List<double>();

    for (int i = 0; i < 10000; i++)
    {
        preIncrement.Add(PreIncrement());
        postIncrement.Add(PostIncrement());
    }

    double letsSeeIfYouAreABadOperator = preIncrement.SkipWhile(x => x == 0).Average();
    double youBetterPerformWell = postIncrement.SkipWhile(x => x == 0).Average();
}

private static double PreIncrement()
{
    DateTime start1 = DateTime.Now;
    int i = 0;

    int x = 1;
    int y = 1;

    for (i = 0; i < 100000; i++)
    {
        x = ++y;
    }
    DateTime end1 = DateTime.Now;

    return (end1 - start1).TotalMilliseconds;
}

private static double PostIncrement()
{
    DateTime start1 = DateTime.Now;
    int i = 0;

    int x = 1;
    int y = 1;

    for (i = 0; i < 100000; i++)
    {
        x = y++;
    }
    DateTime end1 = DateTime.Now;

    return (end1 - start1).TotalMilliseconds;
}
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[^]

GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch4-Dec-19 2:16
mvahoney the codewitch4-Dec-19 2:16 
GeneralRe: postfix increment and decrement can get bent Pin
dan!sh 4-Dec-19 2:18
professional dan!sh 4-Dec-19 2:18 
GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch4-Dec-19 2:19
mvahoney the codewitch4-Dec-19 2:19 
GeneralRe: postfix increment and decrement can get bent Pin
dan!sh 4-Dec-19 2:27
professional dan!sh 4-Dec-19 2:27 
GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch4-Dec-19 2:29
mvahoney the codewitch4-Dec-19 2:29 
GeneralRe: postfix increment and decrement can get bent Pin
dan!sh 4-Dec-19 2:42
professional dan!sh 4-Dec-19 2:42 
GeneralRe: postfix increment and decrement can get bent Pin
honey the codewitch4-Dec-19 2:43
mvahoney the codewitch4-Dec-19 2:43 
GeneralRe: postfix increment and decrement can get bent Pin
F-ES Sitecore4-Dec-19 2:54
professionalF-ES Sitecore4-Dec-19 2:54 
GeneralWSO CCC OTD 2019-12-04 Pin
OriginalGriff3-Dec-19 21:44
mveOriginalGriff3-Dec-19 21:44 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
Pete O'Hanlon3-Dec-19 21:56
mvePete O'Hanlon3-Dec-19 21:56 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
OriginalGriff3-Dec-19 22:11
mveOriginalGriff3-Dec-19 22:11 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
Herman<T>.Instance3-Dec-19 23:09
Herman<T>.Instance3-Dec-19 23:09 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
OriginalGriff3-Dec-19 23:19
mveOriginalGriff3-Dec-19 23:19 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
super4-Dec-19 0:12
professionalsuper4-Dec-19 0:12 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
OriginalGriff4-Dec-19 0:19
mveOriginalGriff4-Dec-19 0:19 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
User 110609794-Dec-19 0:23
User 110609794-Dec-19 0:23 
GeneralRe: WSO CCC OTD 2019-12-04 Pin
OriginalGriff4-Dec-19 0:27
mveOriginalGriff4-Dec-19 0:27 

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.