-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve process tracing, update examples and test names
- Loading branch information
Showing
12 changed files
with
132 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* ex.c | ||
* ex001.c | ||
* | ||
* Copyright (C) 2017 Kristofer Berggren | ||
* All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* ex002.c | ||
* | ||
* Copyright (C) 2017 Kristofer Berggren | ||
* All rights reserved. | ||
* | ||
* cpuusage is distributed under the BSD 3-Clause license, see LICENSE for details. | ||
* | ||
*/ | ||
|
||
/* ----------- Includes ------------------------------------------ */ | ||
#include <fcntl.h> | ||
#include <limits.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
|
||
/* ----------- Function Prototypes ------------------------------- */ | ||
void copy_large_file(); | ||
void copy_medium_file(); | ||
void copy_small_file(); | ||
|
||
|
||
/* ----------- Global Functions ---------------------------------- */ | ||
int main(void) | ||
{ | ||
copy_large_file(); | ||
copy_medium_file(); | ||
copy_small_file(); | ||
return 0; | ||
} | ||
|
||
void copy_large_file() | ||
{ | ||
int large_size = 1024 * 1024 * 1024; | ||
char *buf = calloc(1, large_size); | ||
FILE* fin = fopen("/dev/null", "r"); | ||
FILE* fout = fopen("/dev/null", "w"); | ||
fread(buf, large_size, 1, fin); | ||
fclose(fin); | ||
fwrite(buf, large_size, 1, fout); | ||
fclose(fout); | ||
free(buf); | ||
} | ||
|
||
void copy_medium_file() | ||
{ | ||
int medium_size = 128 * 1024 * 1024; | ||
char *buf = calloc(1, medium_size); | ||
FILE* fin = fopen("/dev/null", "r"); | ||
FILE* fout = fopen("/dev/null", "w"); | ||
fread(buf, medium_size, 1, fin); | ||
fclose(fin); | ||
fwrite(buf, medium_size, 1, fout); | ||
fclose(fout); | ||
free(buf); | ||
} | ||
|
||
void copy_small_file() | ||
{ | ||
int small_size = 1024 * 1024; | ||
char *buf = calloc(1, small_size); | ||
FILE* fin = fopen("/dev/null", "r"); | ||
FILE* fout = fopen("/dev/null", "w"); | ||
fread(buf, small_size, 1, fin); | ||
fclose(fin); | ||
fwrite(buf, small_size, 1, fout); | ||
fclose(fout); | ||
free(buf); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* ex3.cpp | ||
* ex003.cpp | ||
* | ||
* Copyright (C) 2018 Kristofer Berggren | ||
* All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* ex4.cpp | ||
* ex004.cpp | ||
* | ||
* Copyright (C) 2020 Kristofer Berggren | ||
* All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ex005.sh | ||
|
||
sleep 1 | ||
SCRIPTPATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" | ||
${SCRIPTPATH}/ex005b.sh | ||
sleep 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ex005b.sh | ||
|
||
sleep 1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters