Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 397131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:37:12+00:00 2026-05-12T16:37:12+00:00

Is there some reason that identical math operations would take significantly longer in one

  • 0

Is there some reason that identical math operations would take significantly longer in one Silverlight app than in another?

For example, I have some code that takes a list of points and transforms them (scales and translates them) and populates another list of points. It’s important that I keep the original points intact, hence the second list.

Here’s the relevant code (scale is a double and origin is a point):

public Point transformPoint(Point point) {
        // scale, then translate the x
        point.X = (point.X - origin.X) * scale;
        // scale, then translate the y
        point.Y = (point.Y - origin.Y) * scale;
        // return the point
        return point;
    }

Here’s how I’m doing the loop and timing, in case it’s important:

            DateTime startTime = DateTime.Now;
        foreach (Point point in rawPoints) transformedPoints.Add(transformPoint(point));
        Debug.Print("ASPX milliseconds: {0}", (DateTime.Now - startTime).Milliseconds);

On a run of 14356 points (don’t ask, it’s modeled off a real world number in the desktop app), the breakdown is as follows:

Silverlight app #1: 46 ms

Silverlight app #2: 859 ms

The first app is an otherwise empty app that is doing the loop in the MainPage constructor. The second is doing the loop in a method in another class, and the method is called during an event handler in the GUI thread, I think. But should any of that matter, considering that identical operations are happening within the loop itself?

There maybe something huge I’m missing in how threading works or something, but this discrepancy doesn’t make sense to me at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:37:12+00:00Added an answer on May 12, 2026 at 4:37 pm

    In addition to the other comments and answers I’m going to read between the lines a little.

    In the first app you have pretty much this code in isolation running in the MainPage constructor. IWO you’ve create a fresh Silverlight app and slapped this code in it and thats it.

    In the second app you have more actual real world stuff. At the very least you have this code running as the result of a button click on a rudimentory UI. Therein lies the clue.

    Take a blank app and drop a button on it. Run it and click the button, what does the button do? There are animations attached to visual states of the button. This animation (or other animations or loops) are likely running in parrallel with your code when you click the button. Timers (whether you do it properly with StopWatch or not) record elapsed time, not just the time your thread takes. Hence when other threads are doing other things (like animations) your timing will be off.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi im trying to using flashVars however for some reason there not getting sent
For some reason I never see this done. Is there a reason why not?
Is there any reason for the use of 'T' in generics? Is it some
Supposed that for some reason you are only allowed to use static memory in
For some reason, it seems that stopping at a breakpoint during debugging will kill
Is there some means of querying the system tables to establish which tables are
Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
Is there some built-in way to share files between Xen guests? I don't currently
Is there some way to block access from a referrer using a .htaccess file
Is there some way to hide the browser toolbar / statusbar etc in current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.