Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #147523
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: So here's a fun challenge |
| Date | 2019-11-03 14:35 +1300 |
| Message-ID | <h26p7kFa2cqU4@mid.individual.net> (permalink) |
| References | <NNgvF.21265$hh5.17108@fx07.iad> <h26p2rFa2cqU3@mid.individual.net> |
On 03/11/2019 14:33, Ian Collins wrote:
Lets try that again...
Using a slightly modified version of your code in C++ (vector for
arrays, string for the strings), the guts of the combine, sot and dedupe
were:
Strings combined;
combined.reserve(arraySize);
combined.insert( combined.end(), randoms1.begin(), randoms1.end() );
combined.insert( combined.end(), randoms2.begin(), randoms2.end() );
std::sort( combined.begin(), combined.end(), less() );
std::cout << time()-start << "S to sort\n";
start = time();
std::cout << "new sorted array contains " << combined.size() << "
elements\n";
combined.erase(std::unique(combined.begin(), combined.end()),
combined.end());
std::cout << time()-start << "S to dedup\n";
std::cout << "new deduped array contains " << combined.size() << "
elements\n";
Which on my system:
$ g++ -std=c++17 -pedantic -Wextra -Wall -O3 -o fun fun.cpp
$ time ./fun
Item Array 1 Array2
-------------------------------------------------
1 UhyZ4Ex6Sjol xUgSBbJ0d
2 vqF8i6iQQqf kJ3hrdvDoTnv
3 PwaFAx1Q2ZY 8FFoKczj5HB934o
4 iJdX6dtwAkdta i9wOo6QOgMlHLeB
5 QKzTxwXQSn1WH2N 2atg7aVdM6Kobc
6 SMEB90pQ DIvaA8Pt99z6a
7 9MhK1iM50 zsopH4YaDk
8 3iRmiQMe Xet5Olerg4GGnU
9 VPKWiUXc3Epcl2 2QlmL0xP
10 EKNaYyWJd wmijocOEe0w
4999991 EeQ08EVZHkm4hlh Wapv7y34CNNzpAn
4999992 E4KDyvt6FF1MR8 D9QY6eS1HwF
4999993 These These
4999994 are are
4999995 the the
4999996 dupe dupe
4999997 values values
4999998 for for
4999999 each each
5000000 array array
1.26085S to create 10000000 random string elements (+ add dupes)
3.19092S to sort
new sorted array contains 10000000 elements
0.10269S to dedup
new deduped array contains 9999992 elements
0000O3l4xIlD
0002cB9eS3
0002lzVaYmpSH
0007yaIw
000Al1GlOkAfP
000b8bsdj
000ir4XI
000j37ftHAU
000j8SlaN
000JDnZUTsut2tLI
ZZZzN3DyoJU9hOy
ZZZZhpliD
ZzzzgdAwKww
zzZZ4waPKAofj
ZzZYshGXMOzI
zZzyp0NY0
zZzyo7v3
ZzzYLx3l2Nmnc973
zzZydYrs3quxF
ZzZy6FpMdt1Zw
real 0m4.744s
--
Ian.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-02 10:53 -0400
Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 17:08 +0000
Re: So here's a fun challenge Richard Damon <Richard@Damon-Family.org> - 2019-11-02 15:01 -0400
Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 19:38 +0000
Re: So here's a fun challenge Richard Damon <Richard@Damon-Family.org> - 2019-11-02 16:07 -0400
Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:29 -0500
Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 20:36 +0000
Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:33 -0500
Re: So here's a fun challenge Paul <nospam@needed.invalid> - 2019-11-03 20:53 -0500
Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 14:33 +1300
Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 14:35 +1300
Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 00:18 -0400
Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 18:02 +1300
Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-03 11:19 +0000
Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-04 00:33 +1300
Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:39 -0500
Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 11:16 +0100
Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 11:29 +0100
Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 23:34 +1300
Re: So here's a fun challenge Melzzzzz <Melzzzzz@zzzzz.com> - 2019-11-03 11:04 +0000
Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 14:56 +0100
Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 15:36 +0100
Re: So here's a fun challenge nobody@example.org (Scott) - 2019-11-03 17:35 +0000
Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-04 08:03 +1300
Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-04 10:07 -0500
Re: So here's a fun challenge nobody@example.org (Scott) - 2019-11-04 16:06 +0000
Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-04 15:33 -0500
csiph-web