/ Check-in [586c11ed]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modify wordcount so that timer information appears on standard error instead of standard output. Rename the run-wordcount.bash script to run-wordcount.sh and simplify it so that it stands a better chance of running on non-GNU systems.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:586c11ed7cc6b8e2c7181231e37791c2fbc95272
User & Date: drh 2013-11-21 21:40:45
Context
2013-11-21
21:59
Changes some offset and amount parameters from "int" to "u32" to avoid harmless signed/unsigned comparison warnings. check-in: 4e8c5d07 user: drh tags: trunk
21:40
Modify wordcount so that timer information appears on standard error instead of standard output. Rename the run-wordcount.bash script to run-wordcount.sh and simplify it so that it stands a better chance of running on non-GNU systems. check-in: 586c11ed user: drh tags: trunk
21:23
Do not reuse factored constants that might have had their encodings changed. check-in: 487f2036 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Name change from test/run-wordcount.bash to test/run-wordcount.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38




39
40
41
42





43
44
45





46
47
48
49







50
51
52





53
54

55
56
57





58
59

60
61
62






63
64
65
66
#!/bin/bash
#
# This script runs the wordcount program in different ways, comparing
# the output from each.
#


# Run the wordcount command with argument supplied and with --summary.
# Store the results in wc-out.txt and report the run-time.
#
function time_wordcount {
  /usr/bin/time --format='%e %C' ./wordcount --summary $* >wc-out.txt
}

# Compare wc-out.txt against wc-baseline.txt and report any differences.
#
function compare_results {
  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi
}

# Select the source text to be analyzed.
#
if test "x$1" = "x";
then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
fi

# Do test runs
#
rm -f wcdb1.db
time_wordcount wcdb1.db $* --insert
mv wc-out.txt wc-baseline.txt
rm -f wcdb2.db
time_wordcount wcdb2.db $* --insert --without-rowid
compare_results





rm -f wcdb1.db
time_wordcount wcdb1.db $* --replace
compare_results





rm -f wcdb2.db
time_wordcount wcdb2.db $* --replace --without-rowid
compare_results






rm -f wcdb1.db
time_wordcount wcdb1.db $* --select
compare_results







rm -f wcdb2.db
time_wordcount wcdb2.db $* --select --without-rowid
compare_results






time_wordcount wcdb1.db $* --query

mv wc-out.txt wc-baseline.txt
time_wordcount wcdb2.db $* --query --without-rowid
compare_results






time_wordcount wcdb1.db $* --delete

mv wc-out.txt wc-baseline.txt
time_wordcount wcdb2.db $* --delete --without-rowid
compare_results







# Clean up temporary files created.
#
rm -rf wcdb1.db wcdb2.db wc-out.txt wc-baseline.txt
|





<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<









|


|
|
>
>
>
>


|
<
>
>
>
>
>

|
<
>
>
>
>
>


<
<
>
>
>
>
>
>
>

|
<
>
>
>
>
>

<
>

|
<
>
>
>
>
>

<
>

|
<
>
>
>
>
>
>




1
2
3
4
5
6


















7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34

35
36
37
38
39
40
41


42
43
44
45
46
47
48
49
50

51
52
53
54
55
56

57
58
59

60
61
62
63
64
65

66
67
68

69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# This script runs the wordcount program in different ways, comparing
# the output from each.
#



















# Select the source text to be analyzed.
#
if test "x$1" = "x";
then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
fi

# Do test runs
#
rm -f wcdb1.db
./wordcount --timer --summary wcdb1.db $* --insert >wc-out.txt
mv wc-out.txt wc-baseline.txt
rm -f wcdb2.db
./wordcount --timer --summary wcdb2.db $* --insert --without-rowid >wc-out.txt
  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi

rm -f wcdb1.db
./wordcount --timer --summary wcdb1.db $* --replace >wc-out.txt

  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi
rm -f wcdb2.db
./wordcount --timer --summary wcdb2.db $* --replace --without-rowid >wc-out.txt

  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi

rm -f wcdb1.db


./wordcount --timer --summary wcdb1.db $* --select >wc-out.txt
  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi

rm -f wcdb2.db
./wordcount --timer --summary wcdb2.db $* --select --without-rowid >wc-out.txt

  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi


./wordcount --timer --summary wcdb1.db $* --query >wc-out.txt
mv wc-out.txt wc-baseline.txt
./wordcount --timer --summary wcdb2.db $* --query --without-rowid >wc-out.txt

  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi


./wordcount --timer --summary wcdb1.db $* --delete >wc-out.txt
mv wc-out.txt wc-baseline.txt
./wordcount --timer --summary wcdb2.db $* --delete --without-rowid >wc-out.txt

  if cmp -s wc-out.txt wc-baseline.txt;
  then echo hi >/dev/null;
  else echo ERROR:;
       diff -u wc-baseline.txt wc-out.txt;
  fi


# Clean up temporary files created.
#
rm -rf wcdb1.db wcdb2.db wc-out.txt wc-baseline.txt

Changes to test/wordcount.c.

469
470
471
472
473
474
475
476

477
478
479
480
481
482
483
484
485
    }
    sqlite3_finalize(pSelect);
  }


  if( showTimer ){
    sqlite3_int64 elapseTime = realTime() - startTime;
    printf("/* %3d.%03d", (int)(elapseTime/1000), (int)(elapseTime%1000));

    for(i=0; i<argc; i++) if( i!=showTimer ) printf(" %s", argv[i]);
    printf(" */\n");
  }

  if( showSummary ){
    sqlite3_create_function(db, "checksum", -1, SQLITE_UTF8, 0,
                            0, checksumStep, checksumFinalize);
    sqlite3_exec(db, 
      "SELECT 'count(*):  ', count(*) FROM wordcount;\n"







|
>
|
|







469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
    }
    sqlite3_finalize(pSelect);
  }


  if( showTimer ){
    sqlite3_int64 elapseTime = realTime() - startTime;
    fprintf(stderr, "%3d.%03d", (int)(elapseTime/1000),
                                   (int)(elapseTime%1000));
    for(i=0; i<argc; i++) if( i!=showTimer ) fprintf(stderr, " %s", argv[i]);
    fprintf(stderr, "\n");
  }

  if( showSummary ){
    sqlite3_create_function(db, "checksum", -1, SQLITE_UTF8, 0,
                            0, checksumStep, checksumFinalize);
    sqlite3_exec(db, 
      "SELECT 'count(*):  ', count(*) FROM wordcount;\n"