1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
suter [353]
4 years ago
13

Implement a program to measure the impact of application-level buffer sizes on read time. This involves writing to and reading f

rom a large file (say, 2 GB). Vary the application buffer size (say, from 64 bytes to 4 KB). Use timing measurement routines (such as gettimeofday and getitimer on UNIX) to measure the time taken for different buffer sizes. Analyze the results and report your findings: does buffer size make a difference to the overall write time and per-write time?

Computers and Technology
1 answer:
Luda [366]4 years ago
6 0

Answer:

Input file: input.txt

Output file: output.txt

input.txt is a text file of 500 MB.

CODE:

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

#include <fcntl.h>

#include <sys/time.h>

#include <string.h>

#include <unistd.h>

#include <sys/types.h>

double count = 0; // to keep the count of writes

// function which reads from input.txt and writes to output.txt

void fun(int* file_in, int* file_out, int BUFF_SIZE)

{

char *buff = (char *)malloc(BUFF_SIZE*sizeof(char));

while(read(*file_in, buff, BUFF_SIZE) != 0)

{

write(*file_out, buff, strlen(buff));

count++;

}

}

int main(int argc, char* argv[])

{

if(argc == 1)

{

printf("Usage: ./program.c [ buff_size(in bytes) ]\n");

return 0;

}

int file_in,file_out; // input and output file pointers

file_in = open("input.txt",O_RDONLY);

if(file_in == -1)

{

printf("Error while open input.txt \n");

return 0;

}

file_out = open("output.txt",O_WRONLY);

if(file_out == -1)

{

printf("Error occured while opening output.txt\n");

return 0;

}

struct timeval t1, t2; // for capture time

double elapsedTime;

// start timer

gettimeofday(&t1, NULL);

// do something

// ...

fun(&file_in, &file_out, atoi(argv[1]));

// stop timer

gettimeofday(&t2, NULL);

// compute and print the elapsed time in millisec

elapsedTime = (t2.tv_sec - t1.tv_sec)*1000.0; // sec to ms

printf("Overall write time: %lf ms\n",elapsedTime);

printf("Per write time: %lf ms\n", elapsedTime/count);

return 0;

Explanation:

Please see attachment for output

You might be interested in
Suppose testcircle1 and circle1 in listing 9.1 are in two separate files named testcircle1.java and circle1.java, respectively.
zlopas [31]
What is "listing 9.1"?

Stop copying and pasting, or provide us with the resources to answer your question.
8 0
3 years ago
You’re investigating an internal policy violation when you find an e-mail about a serious assault for which a police report need
Rasek [7]

The email specifying who in your company you need to talk to first and what evidence must be turned over to the police is written below.

The manager,

Robotics Plc.

Dear sir,

<h3>Issue of  internal policy violation</h3>

I wish to bring to your notice an issue of concern that has occurred in the company. All employees are mandated to work for the growth of the company and when things or due protocol are not being followed, it can bring an organization down.

I wish to bring to your notice an issue of  internal policy violation  that was done by Mr. Yusuf Thomas on December 2021 that has cost the company to loss about 2million dollars. He used the companies money and also took some of the companies client for himself.

He is still working and no sanction or steps have been taken to reprimand him. I wish that the issue be solved so that others will not follow the same steps.

Thanks and waiting for quick response.

Mary Gina.

Learn more about policy violation from

brainly.com/question/13198827

#SPJ1

6 0
2 years ago
Fonts can be selected from a font group on the ........ tab​
guapka [62]

Answer:

Home

Explanation:

8 0
3 years ago
Read 2 more answers
A manager would like information on the knowledge base searches conducted by customers and call center agents. Which two metrics
RideAnS [48]

Answer:

Option A and Option D are the correct options.

Explanation:

While any information is provided by the manager to its customers which is based on the knowledge of the search conducted.

So, the following knowledge is about the article of the lowest rating and about the search query that has no output.

  • Option B is not correct for the following scenario because the manager is informing about the searches conducted by customers, not for the data category.
  • Option C is not correct for the following scenario because the articles are not created by them.
3 0
3 years ago
Outlines help you visualize the slides and the points you will include on each slide.
kvv77 [185]
I don’t know I think true
6 0
3 years ago
Other questions:
  • A search engine company needs to do a significant amount of computation every time it recompiles its index. For this task, the c
    5·1 answer
  • Design a BCD-to-Gray code decoder. Your decoder will have 4 inputs: A, B, C and D, representing a 4-bit BCD code (A being the MS
    7·2 answers
  • Which of these is a formatting option that you can use to enhance your text document?
    5·2 answers
  • ETC = 220,000 PV = 25,000 AC = 40,000. What is EAC? What does this calculation tell you?
    5·1 answer
  • List the five body functions that monitor homeostasis.
    7·1 answer
  • What is the definition of a performance, such as a poetry reading? O A. A work of art installed in public OB. A presentation of
    14·1 answer
  • Portable Document Format is a proprietary document file type created by Adobe Systems that is compatible with most computer syst
    7·1 answer
  • 1. What is the difference between the wireless network that you provide to your customers versus the wireless network that you w
    5·1 answer
  • As a network engineer, you have been creating patch (straight-through) cables for a network switch. You have plugged in all the
    11·1 answer
  • Which option should Gina click to edit the text contained in a text box on a slide in her presentation?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!