mirror of https://github.com/ecmwf/eccodes.git
Performance: add test for header extraction
This commit is contained in:
parent
35bd4eea43
commit
9190088c6f
|
@ -93,6 +93,7 @@ list( APPEND tests_data_reqd
|
|||
bufr_keys_iter
|
||||
bufr_get_element
|
||||
bufr_wmo_tables
|
||||
bufr_extract_headers
|
||||
bufr_ecc-673
|
||||
bufr_ecc-428
|
||||
bufr_ecc-197
|
||||
|
|
|
@ -21,15 +21,24 @@ int main(int argc,char* argv[])
|
|||
|
||||
assert(argc == 2);
|
||||
|
||||
filename=argv[1];
|
||||
filename = argv[1];
|
||||
err = codes_bufr_extract_headers_malloc(c, filename, &headers, &num_messages);
|
||||
assert(!err);
|
||||
|
||||
for (i=0; i<num_messages; ++i) {
|
||||
codes_bufr_header bh = headers[i];
|
||||
printf("%ld %lu %ld %ld %ld\n",
|
||||
/*
|
||||
* Mimic the behaviour of bufr_get -f -p keys
|
||||
* for testing
|
||||
*/
|
||||
const int has_ecmwf_local = (bh.localSectionPresent == 1 && bh.bufrHeaderCentre == 98);
|
||||
char rdbTypeStr[32] = "not_found";
|
||||
if (has_ecmwf_local) sprintf(rdbTypeStr, "%ld", bh.rdbType);
|
||||
printf("%ld %lu %ld %ld %ld %ld %s\n",
|
||||
bh.edition, bh.totalLength, bh.dataCategory,
|
||||
bh.masterTablesVersionNumber, bh.rdbType);
|
||||
bh.masterTablesVersionNumber,
|
||||
bh.typicalMonth, bh.typicalDay,
|
||||
rdbTypeStr);
|
||||
}
|
||||
|
||||
free(headers);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2019 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
. ./include.sh
|
||||
|
||||
# Define a common label for all the tmp files
|
||||
label="bufr_extract_headers_test"
|
||||
|
||||
temp1="temp.${label}.1"
|
||||
temp2="temp.${label}.2"
|
||||
|
||||
bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
||||
|
||||
KEYS='edition,totalLength,dataCategory,masterTablesVersionNumber,typicalMonth,typicalDay,rdbType'
|
||||
|
||||
for bf in ${bufr_files}; do
|
||||
input=${data_dir}/bufr/$bf
|
||||
$EXEC ${test_dir}/bufr_extract_headers $input > $temp1
|
||||
${tools_dir}/bufr_get -f -p $KEYS $input > $temp2
|
||||
diff $temp1 $temp2
|
||||
done
|
||||
|
||||
rm -f $temp1 $temp2
|
Loading…
Reference in New Issue