Skip to content

Commit 77b823e

Browse files
author
Andy C
committed
[demo/sparse-array] Improve report appearance
This implementation is promising!
1 parent aba381d commit 77b823e

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

cpp/preamble.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ using pretty_asdl::doc;
4141
using runtime_asdl::cmd_value;
4242
using syntax_asdl::command;
4343
using syntax_asdl::expr;
44-
using syntax_asdl::printf_part; // added when self._Percent() used it in function signature
44+
using syntax_asdl::printf_part; // added when self._Percent() used it in
45+
// function signature
4546
using syntax_asdl::proc_sig;
4647
using value_asdl::sh_lvalue; // for builtin_assign.py and builtin_misc.py
4748
using value_asdl::value;

demo/sparse-array.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@
2222
# Usage:
2323
# demo/sparse-array.sh <function name>
2424

25+
TIMEFORMAT='%U'
26+
2527
set -o nounset
2628
set -o pipefail
2729
set -o errexit
2830

31+
my-time() {
32+
local tmp=/tmp/sparse-array
33+
{ time "$@"; } 2> $tmp
34+
echo "$(cat $tmp) seconds"
35+
}
36+
2937
compare-x() {
3038
local x=$1
3139

@@ -35,13 +43,13 @@ compare-x() {
3543
echo ===
3644
echo $osh SparseArray
3745
echo
38-
time sparse-$x $osh
46+
my-time sparse-$x $osh
3947

4048
for sh in bash $osh; do
4149
echo ===
4250
echo $sh
4351
echo
44-
time $sh $0 $x
52+
my-time $sh $0 $x
4553
done
4654
}
4755

mycpp/gc_dict.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void Dict<K, V>::reserve(int num_desired) {
233233
values_ = NewSlab<V>(capacity_);
234234

235235
if (old_k != nullptr) { // rehash if there were any entries
236-
//log("REHASH num_desired %d", num_desired);
236+
// log("REHASH num_desired %d", num_desired);
237237
len_ = 0;
238238
for (int i = 0; i < old_len; ++i) {
239239
set(old_k->items_[i], old_v->items_[i]);

mycpp/gc_dict_test.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,16 +694,16 @@ TEST hash_pileup_bug() {
694694
std::unordered_map<unsigned, bool> hist;
695695

696696
for (int i = 0; i < 24; ++i) {
697-
mops::BigInt index {1 << i};
698-
log("index %ld", index);
697+
mops::BigInt index{1 << i};
698+
// log("index %ld", index);
699699

700700
for (mops::BigInt j = index; j < index + 2000; ++j) {
701701
d->set(j, kEmptyString);
702702
unsigned h = hash_key(j);
703703
hist[h] = true;
704704
// log("%ld %d", j, h);
705705
}
706-
log("len %d", len(d));
706+
// log("len %d", len(d));
707707
}
708708

709709
log("len %d", len(d));
@@ -712,7 +712,6 @@ TEST hash_pileup_bug() {
712712
PASS();
713713
}
714714

715-
716715
GREATEST_MAIN_DEFS();
717716

718717
int main(int argc, char** argv) {

0 commit comments

Comments
 (0)