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 130761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:59:56+00:00 2026-05-11T05:59:56+00:00

Profiling my program and the function print is taking a lot of time to

  • 0

Profiling my program and the function print is taking a lot of time to perform. How can I send ‘raw’ byte output directly to stdout instead of using fwrite, and making it faster (need to send all 9bytes in the print() at the same time to the stdout) ?

void print(){     unsigned char temp[9];      temp[0] = matrix[0][0];     temp[1] = matrix[0][1];     temp[2] = matrix[0][2];     temp[3] = matrix[1][0];     temp[4] = matrix[1][1];     temp[5] = matrix[1][2];     temp[6] = matrix[2][0];     temp[7] = matrix[2][1];     temp[8] = matrix[2][2];      fwrite(temp,1,9,stdout); 

}

Matrix is defined globally to be a unsigned char matrix[3][3];

  • 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. 2026-05-11T05:59:57+00:00Added an answer on May 11, 2026 at 5:59 am

    IO is not an inexpensive operation. It is, in fact, a blocking operation, meaning that the OS can preempt your process when you call write to allow more CPU-bound processes to run, before the IO device you’re writing to completes the operation.

    The only lower level function you can use (if you’re developing on a *nix machine), is to use the raw write function, but even then your performance will not be that much faster than it is now. Simply put: IO is expensive.

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

Sidebar

Related Questions

I'm trying to profile my program. So I compile it with -prof and -auto-all
All sample function I've seen so far avoid, for some reason, returning a string.
Following on from a previous question , I've been playing around with optimizer settings
I'm trying to build a web app using Dojo. I have a form that
I require help with respect to class construction. In my class, I have used
I'm trying to use some code that I wrote on another computer that splits
I have a simple (tested) pycuda app and am trying to profile it. I've
I welcome any help for the following code optimization problem: I have a collection
I am running an application developed with RAD Studio XE or Delphi XE under
I've seen many question regarding the malloc memory consumption, but none of them regarding

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.