This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement light client friendliness changes
- Loading branch information
Showing
20 changed files
with
563 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import time | ||
|
||
from rlp import infer_sedes, encode, decode | ||
from rlp.sedes import big_endian_int, binary, CountableList | ||
from rlp.sedes.serializable import Serializable | ||
|
||
from eth2._utils.numeric import ( | ||
is_power_of_two, | ||
) | ||
|
||
|
||
def slow_is_power_of_two(value): | ||
num = 2 | ||
|
||
if value == 0: | ||
return False | ||
elif value == 1: | ||
return True | ||
|
||
while num < value: | ||
num *= 2 | ||
|
||
return num == value | ||
|
||
|
||
def do_it(): | ||
for i in range(1): | ||
result_1 = is_power_of_two(2**256-1) | ||
print(result_1) | ||
result_2 = slow_is_power_of_two(2**256-1) | ||
print(result_2) | ||
|
||
|
||
round_count = 1 | ||
|
||
try_count = 5 | ||
time_sum = 0 | ||
|
||
for _ in range(try_count): | ||
start = time.time() | ||
for _ in range(round_count): | ||
do_it() | ||
# do_it() | ||
end = time.time() | ||
print('', end - start, 'sec') | ||
time_sum += end - start | ||
|
||
print('avg', time_sum / try_count, 'sec') | ||
|
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
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
Oops, something went wrong.