Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wotb-rs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
typescript
wotb-rs
Commits
2a430bd9
There was a problem fetching the pipeline summary.
Commit
2a430bd9
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[enh] add perfs tests + improve safe memCopy
parent
f9a7afaa
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/index.js
+1
-1
1 addition, 1 deletion
lib/index.js
native/src/lib.rs
+24
-32
24 additions, 32 deletions
native/src/lib.rs
test.bin
+0
-0
0 additions, 0 deletions
test.bin
tests/tests_safe_perfs.js
+56
-0
56 additions, 0 deletions
tests/tests_safe_perfs.js
with
81 additions
and
33 deletions
lib/index.js
+
1
−
1
View file @
2a430bd9
...
@@ -213,7 +213,7 @@ const SafeWoTB = {
...
@@ -213,7 +213,7 @@ const SafeWoTB = {
var
instance
=
Object
.
create
(
SafeWoTB
)
var
instance
=
Object
.
create
(
SafeWoTB
)
instance
.
setFilePath
(
""
)
instance
.
setFilePath
(
""
)
instance
.
setMaxCert
(
this
.
maxCerts
)
instance
.
setMaxCert
(
this
.
maxCerts
)
let
instance_content
=
binding
.
safe_mem_copy
(
this
.
maxCert
s
,
this
.
nodes
,
this
.
sources
);
let
instance_content
=
binding
.
safe_mem_copy
(
this
.
node
s
,
this
.
issued_count
,
this
.
sources
);
instance
.
nodes
=
instance_content
.
nodes
;
instance
.
nodes
=
instance_content
.
nodes
;
instance
.
issued_count
=
instance_content
.
issued_count
;
instance
.
issued_count
=
instance_content
.
issued_count
;
instance
.
sources
=
instance_content
.
sources
;
instance
.
sources
=
instance_content
.
sources
;
...
...
This diff is collapsed.
Click to expand it.
native/src/lib.rs
+
24
−
32
View file @
2a430bd9
...
@@ -27,45 +27,36 @@ static PATH_FINDER: RustyPathFinder = RustyPathFinder {};
...
@@ -27,45 +27,36 @@ static PATH_FINDER: RustyPathFinder = RustyPathFinder {};
fn
safe_mem_copy
(
call
:
Call
)
->
JsResult
<
JsObject
>
{
fn
safe_mem_copy
(
call
:
Call
)
->
JsResult
<
JsObject
>
{
let
scope
=
call
.scope
;
let
scope
=
call
.scope
;
let
max_links
=
try
!
(
try
!
(
call
.arguments
.require
(
scope
,
0
))
.check
::
<
JsInteger
>
())
.value
();
let
arg_nodes
=
try
!
(
try
!
(
try
!
(
call
.arguments
.require
(
scope
,
0
))
.check
::
<
JsArray
>
())
.to_vec
(
scope
));
let
mut
wot
=
RustyWebOfTrust
::
new
(
max_links
as
usize
);
let
arg_issued_count
=
try
!
(
try
!
(
try
!
(
call
.arguments
.require
(
scope
,
1
))
.check
::
<
JsArray
>
())
.to_vec
(
scope
));
let
arg_nodes
=
call
.arguments
.require
(
scope
,
1
);
let
arg_sources
=
try
!
(
try
!
(
try
!
(
call
.arguments
.require
(
scope
,
2
))
.check
::
<
JsArray
>
())
.to_vec
(
scope
));
let
arg_sources
=
call
.arguments
.require
(
scope
,
2
);
let
mut
js_nodes_array
=
JsArray
::
new
(
scope
,
arg_nodes
.len
()
as
u32
);
let
_bool
=
try
!
(
fill_rust_wot
(
scope
,
arg_nodes
,
arg_sources
,
&
mut
wot
));
let
mut
js_issued_count_array
=
JsArray
::
new
(
scope
,
arg_issued_count
.len
()
as
u32
);
let
mut
js_nodes_array
=
JsArray
::
new
(
scope
,
wot
.size
()
as
u32
);
let
mut
js_sources_array
=
JsArray
::
new
(
scope
,
arg_sources
.len
()
as
u32
);
let
mut
js_sources_array
=
JsArray
::
new
(
scope
,
wot
.size
()
as
u32
);
let
mut
i
:
u32
=
0
;
let
mut
rs_issued_counts
=
vec!
[
0
;
wot
.size
()];
for
js_node
in
arg_nodes
{
for
i
in
0
..
wot
.size
()
{
let
_bool
=
try
!
(
JsArray
::
set
(
let
_bool
=
try
!
(
JsArray
::
set
(
*
js_nodes_array
.deref_mut
(),
*
js_nodes_array
.deref_mut
(),
i
as
u32
,
i
,
JsBoolean
::
new
(
scope
,
wot
.is_enabled
(
NodeId
(
i
as
usize
))
.unwrap
()),
try
!
(
js_node
.check
::
<
JsBoolean
>
()),
));
let
sources
=
wot
.get_links_source
(
NodeId
(
i
as
usize
))
.unwrap
();
let
mut
js_sources
=
JsArray
::
new
(
scope
,
sources
.len
()
as
u32
);
let
mut
j
:
u32
=
0
;
for
source
in
sources
{
rs_issued_counts
[
source
.0
]
+=
1
;
let
_bool
=
try
!
(
JsArray
::
set
(
*
js_sources
.deref_mut
(),
j
,
JsInteger
::
new
(
scope
,
source
.0
as
i32
),
));
));
j
+=
1
;
i
+=
1
;
}
}
let
mut
i
:
u32
=
0
;
for
js_issued_count
in
arg_issued_count
{
let
_bool
=
try
!
(
JsArray
::
set
(
let
_bool
=
try
!
(
JsArray
::
set
(
*
js_sources
_array
.deref_mut
(),
*
js_issued_count
_array
.deref_mut
(),
i
as
u32
,
i
,
js_sources
,
try
!
(
js_issued_count
.check
::
<
JsInteger
>
())
,
));
));
i
+=
1
;
}
}
let
mut
js_issued_count_array
=
JsArray
::
new
(
scope
,
wot
.size
()
as
u32
);
let
mut
i
:
u32
=
0
;
let
mut
i
:
u32
=
0
;
for
issued_count
in
rs_issued_count
s
{
for
js_source
in
arg_source
s
{
let
_bool
=
try
!
(
JsArray
::
set
(
let
_bool
=
try
!
(
JsArray
::
set
(
*
js_issued_count
_array
.deref_mut
(),
*
js_sources
_array
.deref_mut
(),
i
,
i
,
JsInteger
::
new
(
scope
,
issued_count
as
i32
),
try
!
(
js_source
.check
::
<
JsArray
>
()
),
));
));
i
+=
1
;
i
+=
1
;
}
}
...
@@ -74,6 +65,7 @@ fn safe_mem_copy(call: Call) -> JsResult<JsObject> {
...
@@ -74,6 +65,7 @@ fn safe_mem_copy(call: Call) -> JsResult<JsObject> {
let
_bool
=
try
!
(
JsObject
::
set
(
*
js_wot
.deref_mut
(),
"issued_count"
,
js_issued_count_array
,));
let
_bool
=
try
!
(
JsObject
::
set
(
*
js_wot
.deref_mut
(),
"issued_count"
,
js_issued_count_array
,));
let
_bool
=
try
!
(
JsObject
::
set
(
*
js_wot
.deref_mut
(),
"sources"
,
js_sources_array
,));
let
_bool
=
try
!
(
JsObject
::
set
(
*
js_wot
.deref_mut
(),
"sources"
,
js_sources_array
,));
Ok
(
js_wot
)
Ok
(
js_wot
)
}
}
fn
unsafe_mem_copy_from_safe
(
call
:
Call
)
->
JsResult
<
JsInteger
>
{
fn
unsafe_mem_copy_from_safe
(
call
:
Call
)
->
JsResult
<
JsInteger
>
{
...
...
This diff is collapsed.
Click to expand it.
test.bin
+
0
−
0
View file @
2a430bd9
No preview for this file type
This diff is collapsed.
Click to expand it.
tests/tests_safe_perfs.js
0 → 100644
+
56
−
0
View file @
2a430bd9
"
use strict
"
;
const
addon
=
require
(
'
./../lib/index
'
);
var
assert
=
require
(
'
assert
'
);
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
var
should
=
require
(
'
should
'
);
testsSafePerfs
()
function
testsSafePerfs
()
{
function
newInstance
(
launchSafeTests
)
{
return
()
=>
{
let
wot
=
addon
.
newEmptySafeMemoryInstance
(
100
);
launchSafeTests
(
wot
);
}
}
describe
(
"
wotb-rs performances tests
"
,
()
=>
{
describe
(
'
Basic operations
'
,
newInstance
((
wot
)
=>
{
it
(
'
should add 1_000_000 nodes
'
,
function
()
{
for
(
let
i
=
0
;
i
<
1000000
;
i
++
)
{
should
.
equal
(
wot
.
addNode
(),
i
);
}
should
.
equal
(
wot
.
getWoTSize
(),
1000000
);
});
it
(
'
should add 500_000 links
'
,
function
()
{
for
(
let
i
=
0
;
i
<
500000
;
i
++
)
{
for
(
let
j
=
0
;
j
<
1
;
j
++
)
{
wot
.
addLink
(
i
,
Math
.
random
*
(
999999
))
}
}
});
it
(
'
should make a real mem copy
'
,
function
()
{
let
wot2
=
wot
.
memCopy
();
wot2
.
addNode
();
wot2
.
addLink
(
0
,
1
);
should
.
equal
(
wot
.
getWoTSize
(),
1000000
);
should
.
equal
(
wot
.
existsLink
(
0
,
1
),
false
);
});
it
(
'
should make a unsafe mem copy
'
,
function
()
{
var
unsafe_wot
=
wot
.
unsafeMemCopy
();
});
it
(
'
should make a unsafe mem copy and copy them
'
,
function
()
{
var
unsafe_wot
=
wot
.
unsafeMemCopy
();
unsafe_wot
.
memCopy
();
});
}));
});
}
\ No newline at end of file
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