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
What is an administrator?
Drupady [299]
A person responsible for running a business, organization, etc.
3 0
3 years ago
Describe two different examples of potential conflicts, and explain why these conflicts can have a negative impact on
Julli [10]

Answer:

A conflict is a situation in which two or more parties with opposing interests collide in their positions when trying to obtain a benefit or satisfy their needs. Thus, for example, if two people want to obtain the same thing, there will be a conflict of interest between those people, since only one of them will be able to satisfy their need.

Thus, two examples of conflict are, on the one hand, the clash of interests over a particular thing (two people want the same thing or position); and on the other, the conflict between two people with different and antagonistic personalities (an extroverted and noisy person against another introverted and reserved).

In all cases, a conflict between two people who are working on the same project could lead to a series of negativities that could affect its outcome.

6 0
3 years ago
The user enters a URL into a web browser, the web browser sends the information to the DNS server to look up the IP address, the
Olegator [25]

Answer:

d

Explanation:

6 0
3 years ago
NEED BY 15 MINUTES PLEASE! WILL MARK BRAINLIEST!You can create special effects in an image using a camera or a photo-editing too
vovangra [49]

Answer:

Special Lenses For Special Effects. ... These specialty lenses may be designed with movable focal planes for amazing depth of field, or built to focus extremely close to tiny subjects for macro enlargements, or even to produce a specific type of soft focus that's flattering for portraits

The meaning of photo editing is the act of altering an image, simply put. But that’s oversimplifying a subject which is quite complex.

For example, some photo editing techniques are done manually, while others are conducted through automated software. Some photo editing is even done offline, on actual photographs, posters or other printed collateral.

Other terms for photo editing:

Image editing

Post-processing

Image/photo manipulation

Photoshopping

Image/photo enhancement

Explanation:

so they both are alike because they can both be used to edit photos and both are great to use

3 0
3 years ago
I just downloaded this song and if any one wants to listen to it then go ahead and do that. It’s called Trap Music 2018 âa bass
xz_007 [3.2K]

Answer:

ok

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Briefly explain the cooling mechanism implemented in a fanless laptop
    15·1 answer
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • What mass of nh3 can be made from 35g of n2?
    14·1 answer
  • Nina aspires to be a digital media specialist. What should Nana be familiar with in order to pursue this career?
    9·2 answers
  • Which of the following is the best definition of being a “digital citizen”?
    6·2 answers
  • Beth would like to run an nmap scan against all of the systems on her organization's private network. These include systems in t
    15·1 answer
  • The camera still is bad even with the new iPhone xr and especially in low light it is even worst because you can see the pixels
    15·1 answer
  • The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and eac
    12·1 answer
  • Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not
    10·1 answer
  • The memory used by the CPU to temporarily hold data while processing is called what?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!