我的表格内置#!/bin/bash
# ----- BEGIN: CUSTOMIZE HERE
numDirs=${1:-1000} # Number of directories to create
numFilesPerDir=${2:-50} # Number of target files per directory to delete
numFilesOtherPerDir=${3:-$(( numFilesPerDir * 2 ))} # Number of additional files per directory.
# Define the commands to test here, as you would execute them directly.
IFS=$'\n' read -d '' -ra cmdLines <<'EOF'
find . -name '*out*' -print0 | xargs -0 rm
find . -name '*out*' -print0 | xargs -0 -P2 rm
find . -name '*out*' -print0 | xargs -0 -P0 rm
find . -name '*out*' -delete
find . -mindepth 2 -maxdepth 2 -name '*out*' -delete
perl -e 'unlink <*/*out*>'
find . -name '*out*' | perl -e 'chomp(@a=<>); unlink @a'
find . -name '*out*' | parallel --pipe -n 1000 -q perl -e 'chomp(@a=<>); unlink @a'
find . -name '*out*' | parallel --pipe -n 1000 perl -nle 'unlink'
find . -name '*out*' | parallel -n 1000 rm
find . -name '*out*' | parallel --xargs rm
rm */*out*
EOF
# ----- END: CUSTOMIZE HERE
# Set up execution of the teardown function on exit.
keepTmpDir=0
trap '(( keepTmpDir )) || teardownOnExit' EXIT
# Initial, one-time setup.
setupInitial() {
tmpDir=/tmp/test-$$
[[ -e $tmpDir ]] && { echo "Directory $tmpDir already exists. To run these tests, remove it first." >&2; exit 2; }
mkdir "$tmpDir" && cd "$tmpDir" || exit
}
# Teardown on overall exit.
teardownOnExit() {
# echo "Removing $tmpDir..."
rm -rf "$tmpDir"
}
# Set up the dirs. and files for each test.
setupBeforeEachTest() {
# To save time, only recreate the deleted files to set up for subsequent
# test runs.
local recreateFilesOnly=0
[[ -d '1' ]] && recreateFilesOnly=1
local dirNames=( $(seq $numDirs) )
local fileNames=( $(seq $numFilesPerDir) )
local fileNames=( "${fileNames[@]/%/-out}" )
(( recreateFilesOnly )) || fileNamesOther=( $(seq $numFilesOtherPerDir) )
(( recreateFilesOnly )) || mkdir -p "${dirNames[@]}" || exit
for d in "${dirNames[@]}"; do
cd "$d"
touch "${fileNames[@]}"
(( recreateFilesOnly )) || touch "${fileNamesOther[@]}"
cd ..
done
# Activate the next line to inspect the temp. dir. before each test run.
# showInFileManager "$PWD"; read -p "Attempting to show '$PWD' in the file manager; press Enter to continue."
}
# Verify that the most recent test ran correctly.
verifyAfterEachTest() {
local count=$(find . -name '*out*' | wc -l)
(( count == 0 )) || { echo " ERROR: There are still $count '*out*' file(s) present." >&2; return 1; }
}
# --- Generic helper functions
showInFileManager() {
local dir=$1
case $(uname) in
Linux)
xdg "$dir"
;;
Darwin)
open "$dir"
;;
*)
echo "WARNING: Don't know how to open a dir. in the platform's file manager on $(uname)." >&2
;;
esac
}
# Helper function for resetting the disk cache between runs.
resetDiskCache() {
case $(uname) in
Linux)
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
;;
Darwin)
sudo sync && sudo purge
;;
*)
echo "ERROR: Don't know how to clear caches on $(uname)." >&2
exit 1
;;
esac
}
# ==== MAIN BODY
setupInitial || exit
cat <<EOF
Tests will run in dir. $tmpDir, which will be removed on termination.
Parameters:
# of subdirs.: $numDirs
# of target files in each subdir.: $numFilesPerDir
# of other files in each subdir.: $numFilesOtherPerDir
EOF
# To reset the disk cache, we need `sudo` - prompt up front.
sudo -v -p 'Please enter your password to allow clearing the disk cache between runs, which requires `sudo`: ' || exit 2
# Make `time` report total time elapsed only.
TIMEFORMAT='%3R'
quiet=0 # Set this to 1 to suppress the status messages
{
# Loop over all tests
for cmdLine in "${cmdLines[@]}"; do
(( quiet )) || echo ">> $cmdLine <<"
(( quiet )) || echo " setting up..."
setupBeforeEachTest || exit
resetDiskCache || exit
(( quiet )) || echo " running..."
timing=$({ time eval "$cmdLine"; } 2>&1 1>/dev/tty)
(( quiet )) || echo " verifying..."
if verifyAfterEachTest; then
echo " OK"
else
echo " FAILED"
timing=$'(n/a)\t'"$(sed '$d' <<<"$timing")"
fi
printf '%s\t%s\n' "$cmdLine" "$timing" >&3
done 3>&1 >/dev/tty
(( quiet )) || echo "--- RESULTS (in secs., fastest first) ---" >/dev/tty
# Sort and columnate the results below.
} |
sort -t$'\t' -k2,2n |
column -s$'\t' -t
。
我正在通过Bootstrap-Table
刷新数据。从文档中,似乎我应该销毁表,然后重建它。
我已成功销毁该表,但刷新它并没有,并且控制台中没有错误。
Javascript
答案 0 :(得分:1)
您需要使用&#39;加载&#39;功能。不需要销毁。
像:
var newData = [
{"name": "new data!"},
];
$('#table').bootstrapTable('load', {
data: newData
});
我更新了你的小提琴:http://jsfiddle.net/qxw5y72f/