Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RaspberryCloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kk1205
RaspberryCloud
Commits
c98678c5
Commit
c98678c5
authored
Nov 30, 2015
by
kk1205
Browse files
Options
Downloads
Patches
Plain Diff
apró fix
parent
ec5a2bd4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/Source/app/Application.cpp
+96
-18
96 additions, 18 deletions
program/Source/app/Application.cpp
program/Source/cache/LFUCache.cpp
+1
-1
1 addition, 1 deletion
program/Source/cache/LFUCache.cpp
with
97 additions
and
19 deletions
program/Source/app/Application.cpp
+
96
−
18
View file @
c98678c5
#include
<string.h>
#include
<string.h>
#include
<ctime>
#include
<ctime>
#include
<random>
#include
"../logger/Logger.h"
#include
"../logger/Logger.h"
#include
"Application.h"
#include
"Application.h"
#include
"../cloud/LocalCloudAdapter.h"
#include
"../cloud/LocalCloudAdapter.h"
...
@@ -10,6 +11,8 @@
...
@@ -10,6 +11,8 @@
#include
"../cache/LRUCache.h"
#include
"../cache/LRUCache.h"
#include
"../cache/LFUCache.h"
#include
"../cache/LFUCache.h"
#include
<boost/lexical_cast.hpp>
using
namespace
std
;
using
namespace
std
;
/**
/**
...
@@ -242,18 +245,20 @@ int main2(int argc, char **argv){
...
@@ -242,18 +245,20 @@ int main2(int argc, char **argv){
}
}
void
addFile
(
Application
&
application
,
string
localid
,
string
destid
)
{
void
addFile
(
Application
&
application
,
string
localid
,
string
destid
)
{
cout
<<
application
.
ui
.
addFile
(
localid
,
destid
)
<<
endl
;
//cout <<
application
.
ui
.
addFile
(
localid
,
destid
);
//<< endl;
}
}
void
getFile
(
Application
&
application
,
string
fileid
)
{
void
getFile
(
Application
&
application
,
string
fileid
)
{
FileDescriptor
fileDesc
=
FileDescriptor
(
fileid
);
FileDescriptor
fileDesc
=
FileDescriptor
(
fileid
);
ReturnableFile
returned
=
application
.
ui
.
getFile
(
fileDesc
);
ReturnableFile
returned
=
application
.
ui
.
getFile
(
fileDesc
);
if
(
returned
.
isValid
())
{
//
if (returned.isValid()) {
cout
<<
"Successfully downloaded: "
<<
returned
.
getLocalFileId
()
<<
endl
;
//
cout << "Successfully downloaded: " << returned.getLocalFileId() << endl;
}
//
}
else
{
//
else {
cout
<<
"ERROR with getting: "
<<
returned
.
getLocalFileId
()
<<
endl
<<
returned
.
getErrorMessage
()
<<
endl
;
//
cout << "ERROR with getting: " << returned.getLocalFileId() << endl << returned.getErrorMessage() << endl;
}
//
}
}
}
void
getFileList
(
Application
&
application
)
{
void
getFileList
(
Application
&
application
)
{
...
@@ -279,7 +284,7 @@ int test1(){
...
@@ -279,7 +284,7 @@ int test1(){
application
.
cm
.
addCloud
(
make_shared
<
LocalCloudAdapter
>
());
application
.
cm
.
addCloud
(
make_shared
<
LocalCloudAdapter
>
());
application
.
cm
.
addCloud
(
make_shared
<
DropboxAdapter
>
());
application
.
cm
.
addCloud
(
make_shared
<
DropboxAdapter
>
());
application
.
cm
.
addCloud
(
make_shared
<
FTPAdapter
>
());
//
application.cm.addCloud(make_shared<FTPAdapter>());
string
dataFolder
=
"C:
\\
Users
\\
krisz
\\
raspberrycloud
\\
skeleton
\\
Program
\\
data
\\
"
;
string
dataFolder
=
"C:
\\
Users
\\
krisz
\\
raspberrycloud
\\
skeleton
\\
Program
\\
data
\\
"
;
string
fragFolder
=
"C:
\\
Users
\\
krisz
\\
raspberrycloud
\\
skeleton
\\
Program
\\
temp
\\
"
;
string
fragFolder
=
"C:
\\
Users
\\
krisz
\\
raspberrycloud
\\
skeleton
\\
Program
\\
temp
\\
"
;
...
@@ -292,7 +297,7 @@ int test1(){
...
@@ -292,7 +297,7 @@ int test1(){
Cache
*
cacheToSetup
;
Cache
*
cacheToSetup
;
int
cacheSize
=
3
;
int
cacheSize
=
16
;
//cacheToSetup = new NoCache();
//cacheToSetup = new NoCache();
cacheToSetup
=
new
FIFOCache
(
cacheSize
);
cacheToSetup
=
new
FIFOCache
(
cacheSize
);
//cacheToSetup = new LRUCache(cacheSize);
//cacheToSetup = new LRUCache(cacheSize);
...
@@ -310,23 +315,96 @@ int test1(){
...
@@ -310,23 +315,96 @@ int test1(){
application
.
ui
.
setComputeOnPi
(
false
);
application
.
ui
.
setComputeOnPi
(
false
);
double
elapsed_secs
=
0
;
clock_t
begin
=
clock
();
clock_t
begin
=
clock
();
addFile
(
application
,
"1.html"
,
"1h"
);
addFile
(
application
,
"1.html"
,
"1.html"
);
addFile
(
application
,
"2.html"
,
"2h"
);
addFile
(
application
,
"2.html"
,
"2.html"
);
addFile
(
application
,
"3.html"
,
"3h"
);
addFile
(
application
,
"3.html"
,
"3.html"
);
addFile
(
application
,
"4.html"
,
"4.html"
);
addFile
(
application
,
"5.html"
,
"5.html"
);
addFile
(
application
,
"6.html"
,
"6.html"
);
addFile
(
application
,
"7.html"
,
"7.html"
);
addFile
(
application
,
"8.html"
,
"8.html"
);
addFile
(
application
,
"9.html"
,
"9.html"
);
addFile
(
application
,
"10.html"
,
"10.html"
);
addFile
(
application
,
"11.html"
,
"11.html"
);
addFile
(
application
,
"12.html"
,
"12.html"
);
addFile
(
application
,
"13.html"
,
"13.html"
);
addFile
(
application
,
"14.html"
,
"14.html"
);
addFile
(
application
,
"15.html"
,
"15.html"
);
addFile
(
application
,
"16.html"
,
"16.html"
);
addFile
(
application
,
"17.html"
,
"17.html"
);
addFile
(
application
,
"18.html"
,
"18.html"
);
addFile
(
application
,
"19.html"
,
"19.html"
);
addFile
(
application
,
"20.html"
,
"20.html"
);
std
::
default_random_engine
generator
;
std
::
normal_distribution
<
double
>
distribution
(
10.0
,
4.0
);
const
int
nrolls
=
300
;
// number of experiments
const
double
nfiles
=
20.0
;
// number of files
int
out
=
0
;
double
elapsed_secs
=
0
;
for
(
int
i
=
0
;
i
<
nrolls
;
++
i
)
{
if
(
i
%
10
==
0
)
{
cout
<<
i
*
100
/
nrolls
<<
"%"
<<
endl
;
}
int
random1
=
-
1.0
;
int
random2
=
-
1.0
;
double
number1
=
distribution
(
generator
);
if
((
number1
>=
0.0
)
&&
(
number1
<
nfiles
))
{
random1
=
int
(
number1
);
}
else
{
out
++
;
}
double
number2
=
distribution
(
generator
);
if
((
number2
>=
0.0
)
&&
(
number2
<
nfiles
))
{
random2
=
int
(
number2
);
}
else
{
out
++
;
}
if
(
random1
>
0
&&
random2
>
0
&&
random1
<
20
&&
random2
<
20
)
{
string
file1
=
boost
::
lexical_cast
<
string
>
(
random1
)
+
".html"
;
string
file2
=
boost
::
lexical_cast
<
string
>
(
random2
)
+
".html"
;
addFile
(
application
,
file1
,
file1
);
getFile
(
application
,
file2
);
}
}
clock_t
end
=
clock
();
elapsed_secs
+=
double
(
end
-
begin
);
deleteFile
(
application
,
"1.html"
);
deleteFile
(
application
,
"1.html"
);
deleteFile
(
application
,
"2.html"
);
deleteFile
(
application
,
"2.html"
);
deleteFile
(
application
,
"3.html"
);
deleteFile
(
application
,
"3.html"
);
deleteFile
(
application
,
"4.html"
);
deleteFile
(
application
,
"5.html"
);
deleteFile
(
application
,
"6.html"
);
deleteFile
(
application
,
"7.html"
);
deleteFile
(
application
,
"8.html"
);
deleteFile
(
application
,
"9.html"
);
deleteFile
(
application
,
"10.html"
);
deleteFile
(
application
,
"11.html"
);
deleteFile
(
application
,
"12.html"
);
deleteFile
(
application
,
"13.html"
);
deleteFile
(
application
,
"14.html"
);
deleteFile
(
application
,
"15.html"
);
deleteFile
(
application
,
"16.html"
);
deleteFile
(
application
,
"17.html"
);
deleteFile
(
application
,
"18.html"
);
deleteFile
(
application
,
"19.html"
);
deleteFile
(
application
,
"20.html"
);
application
.
cfs
.
getCache
()
->
clearCache
();
application
.
cfs
.
getCache
()
->
clearCache
();
clock_t
end
=
clock
();
cout
<<
"Out: "
<<
out
<<
endl
;
elapsed_secs
+=
double
(
end
-
begin
);
cout
.
precision
(
15
);
cout
.
precision
(
15
);
cout
<<
"Spent time:"
<<
elapsed_secs
<<
endl
;
cout
<<
"Spent time:"
<<
elapsed_secs
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
program/Source/cache/LFUCache.cpp
+
1
−
1
View file @
c98678c5
...
@@ -77,7 +77,7 @@ bool LFUCache::addFile(std::string localFileID) {
...
@@ -77,7 +77,7 @@ bool LFUCache::addFile(std::string localFileID) {
ofstream
dst
(
cacheFolder
+
localFileID
,
ios
::
binary
);
ofstream
dst
(
cacheFolder
+
localFileID
,
ios
::
binary
);
if
(
dst
)
{
if
(
dst
)
{
int
minAge
=
2147483647
;
int
minAge
=
2147483647
;
for
(
int
i
=
0
;
i
<
m
inAg
e
;
i
++
)
for
(
int
i
=
0
;
i
<
m
axSiz
e
;
i
++
)
{
{
if
(
files
[
i
].
used
<
minAge
)
{
if
(
files
[
i
].
used
<
minAge
)
{
minAge
=
files
[
i
].
used
;
minAge
=
files
[
i
].
used
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment