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

  • SEARCH
  • Home
  • 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 6863241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:45:30+00:00 2026-05-27T02:45:30+00:00

In an effort to brush up on some multithreading/sorting fun, I decided to put

  • 0

In an effort to brush up on some multithreading/sorting fun, I decided to put together a Quicksort test (written in Objective-C) that uses Grand Central Dispatch to determine how much faster it is to leverage multicore machines.

main.m

QuickSort.m

This is the output generated:

2011-11-27 13:10:55.595 Quicksort[1583:707] Took 4.731876 seconds to sort 1000000 elements with NO GCD
2011-11-27 13:10:55.670 Quicksort[1583:707] Took 0.070753 seconds to sort 1000000 elements WITH GCD

It’s a fairly simple algorithm, using the Simple version mentioned on the Wikipedia page:

Quicksort on Wikipedia

I’m running this on an i7 machine, so would expect the performance increase to be on the order of 8x or so. Instead, the algorithm is approximately 60-70x faster when using Grand Central Dispatch.

Is the difference caused by a coding error on my part, or is there a technical advantage to using GCD that I’m just not aware of?

  • 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-27T02:45:31+00:00Added an answer on May 27, 2026 at 2:45 am

    You have got an error somewhere in your code, I changed the lines

        NSLog(@"Took %f seconds to sort %lu elements WITH GCD", duration, NUM_ELEMENTS);
    

    to

        NSLog(@"Took %f seconds to sort %lu elements WITH GCD", duration, [sorted count]);
    

    now the output is

    2011-11-27 18:40:28.020 qs[37855:707] Took 5.412689 seconds to sort 1000000 elements with NO GCD
    2011-11-27 18:40:28.104 qs[37855:707] Took 0.082455 seconds to sort 1 elements WITH GCD
    

    Still investigating why however…

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

Sidebar

Related Questions

I decided to put some effort in building a web browser from scratch. What
After a lot of effort, I've managed to piece together a function that deletes
In an effort to understand the capabilities of functional programming I put together a
There is an entity Effort that has a property List and a property AdType
I have uncovered another problem in the effort that we are making to port
How can one with minimal effort (using some already existing facility, if possible) convert
I've been tinkering with some code in a effort to understand OOP using c.
I've been using the following test/function pair in an effort to only attach functions
In the last years I have put lot of effort in c# and left
In an effort to speed up my test suite I profiled it and got

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.