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]
3 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]3 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
___________ is a computer processor which incorporates the functions of a computer's central processing unit (CPU) on a single i
Yanka [14]

Answer:

Microprocessor

Explanation:

A microprocessor is a programmable chip that incorporates in itself the functions of a computer's central processing unit. It contains millions of small components such as transistors and resistors. In fact, the microprocessor is sometimes called the CPU itself as it contains an Arithmetic Logic Unit(ALU), a control unit and register array.

They work at a very high speed due to the components that they contain and are available at relatively low cost. They are portable, reliable and compared to vacuum tubes, they generate less heat.

<em>Hope this helps!</em>

6 0
3 years ago
Read 2 more answers
Complete this assignment in Python 3.x. Make sure you have downloaded the software, and it is installed correctly.
Masja [62]

Answer:

The program code is completed below

Explanation:

Program Code:

"""

  Your Name

  Course Name, Section (example: ENTD200 B002 Spr15)

  Instructor name

  Week #

  Date completed

"""

months = ["January ", "February", "March", "April", "May", "June", "July"

, "August", "September", "October", "November", "December"]

for i in range(0,12):

print("Month",i+1, "is" , months[i])

6 0
2 years ago
What could be a summary sentence or phrase that captures your writing experience?
Natasha2012 [34]

<u>Answer:</u>

<em>A summary sentence should brief the whole content “what so ever the length of the original content” may be. </em>

For example, if you take a story, <em>moral will be the good example of summary. </em>One another example is when the teacher taught concept in the classroom, in the last few minutes of the class the teacher <em>would brief the whole into smaller points. </em>

Even nowadays, people go and visit movies only after seeing the review online. So once again the review is a small brief about the movie in one or two lines. <em>It should be crisp, use cherry-picked words, etc.</em>

3 0
3 years ago
I know that this will be taken down for not being a real question but is anyone else not able to search for anything? I can type
Schach [20]

Answer:

Sameee

Explanation:

6 0
3 years ago
What is this affect in photography?? pls help!!
dlinn [17]
Its called tilt shift effect
3 0
3 years ago
Other questions:
  • If your address is 10 B Street, what are the first three bytes in ASCII
    12·1 answer
  • Some technologies like vertical farming have a number of negative effects. Which is a negative outcome of this technology? A. In
    10·1 answer
  • How do you convert a decimal to binary?
    9·2 answers
  • Try writing pseudo code that describes how your device uses input data to perform the action that you want.
    9·1 answer
  • What is a good way to minimize technical problems with your computer
    10·1 answer
  • Identify which statement explains why a programmer would break a logic problem into steps.
    13·2 answers
  • What is the output of the following program?
    10·1 answer
  • How many report charts can be added to the account page layout to meet this requirement? A sales manager would like to look at a
    14·1 answer
  • What can happen if you do not follow the directions when cooking or baking? (Give 4 examples in a sentence each)
    8·1 answer
  • Which of the following is the key business objective behind the technologies implemented by PCL Construction, as discussed in th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!