language
stringclasses
15 values
src_encoding
stringclasses
34 values
length_bytes
int64
6
7.85M
score
float64
1.5
5.69
int_score
int64
2
5
detected_licenses
listlengths
0
160
license_type
stringclasses
2 values
text
stringlengths
9
7.85M
Java
UTF-8
1,824
3.84375
4
[]
no_license
package chapter2.item2.builderPattern; /*Builder Pattern : Use when there are 4 or more optional params with similar data types. * Advantages * a) Improved readability/writeability of client code. * b) Avoids parameter swapping due to explicit parameter naming while setting them up. * c) Does not MANDATE MUTABILITY - object cab be constructed with all the required parameters at once. * (although at that point, it isn't much different than a constructor with all the req parameters). * * DISADVANTAGES * a) Object construction requires construction of a builder first - can be performance impacting. * */ public class Car { // Required private String name; private String make; // Optional private int year; private int license; private String color; public String getName() { return name; } public static class Builder { private String name; private String make; private int year; private int license; private String color; /*public Builder() {} */ public Builder(String name, String make) { this.name = name; this.make = make; } public Builder year(int year) { this.year = year; return this; } public Builder license(int license) { this.license = license; return this; } public Builder color(String color) { this.color = color; return this; } public Car build() { return new Car(this); } } private Car(Builder builder) { this.make = builder.make; this.name = builder.name; this.color = builder.color; this.license = builder.license; this.year = builder.year; } }
Java
UTF-8
1,563
3.640625
4
[ "Apache-2.0" ]
permissive
import java.util.Stack; class ListNode { int val; ListNode next; ListNode(int x) { val = x; } public ListNode(int[] arr) { if (arr == null || arr.length == 0) { throw new IllegalArgumentException("数组不能为空"); } this.val = arr[0]; ListNode curr = this; for (int i = 1; i < arr.length; i++) { curr.next = new ListNode(arr[i]); curr = curr.next; } } @Override public String toString() { StringBuilder s = new StringBuilder(); ListNode cur = this; while (cur != null) { s.append(cur.val); s.append(" -> "); cur = cur.next; } s.append("NULL"); return s.toString(); } } public class Solution { public int getDecimalValue(ListNode head) { ListNode curNode = head; Stack<Integer> stack = new Stack<>(); while (curNode != null) { stack.push(curNode.val); curNode = curNode.next; } int res = 0; int base = 1; while (!stack.isEmpty()) { res += base * stack.pop(); base *= 2; } return res; } public static void main(String[] args) { // int[] arr = {1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0}; int[] arr = {1, 0, 1}; ListNode head = new ListNode(arr); Solution solution = new Solution(); int res = solution.getDecimalValue(head); System.out.println(res); } }
C++
UTF-8
1,387
2.59375
3
[ "MIT" ]
permissive
#include "ArgumentsParser.hpp" #include "Error.hpp" #include "Range.hpp" #include "Token.hpp" namespace cmake::language { //----------------------------------------------------------------------------- tl::expected<Token, Error> Parser<ElementType::Arguments>::Parse(Range r) { Token result; result.type = ElementType::Arguments; tl::expected<Token, Error> argument = Parser<ElementType::Argument>{}.Parse(r); if (argument) { result.children.push_back(*argument); } Range nextRange = argument ? Range{ argument->range.end, r.end } : r; tl::expected<Token, Error> separatedArgs = Parser<ElementType::SeparatedArguments>{}.Parse(nextRange); tl::expected<Token, Error> lastSeparatedArgs = separatedArgs; while (separatedArgs) { result.children.push_back(*separatedArgs); lastSeparatedArgs = separatedArgs; separatedArgs = Parser<ElementType::SeparatedArguments>{}.Parse(Range{ separatedArgs->range.end, r.end }); } if (!lastSeparatedArgs) { if (!argument) { Error err; err.message = "No argument available."; err.context = r.begin; return tl::make_unexpected(err); } result.range = Range{ r.begin, argument->range.end }; } else { result.range = Range{ r.begin, lastSeparatedArgs->range.end }; } return result; } }
C++
UTF-8
1,321
3.78125
4
[]
no_license
/* * Name: Abeed Alibhai, Rahul Bablani, Natasha DeCoste * MacID: alibhaa, bablanr, decostn * Student Number: 1428809, 1418434, 1206976 * Description: The multiplication class is a child class of the Arithmetic Expression class. It recursively multplies the evaluate of both the left side and the right side. */ #include <iostream> #include <string> #include "Multiplication.h" //header has the declaration of the defintions listed below using namespace std; Multiplication::Multiplication(string a, string b) : ArithmeticExpression(a) { //constructs the multiplication object from the Aritmetic Expression left = new ArithmeticExpression(a); //assigning left and right pointers to the 2 strings right = new ArithmeticExpression(b); //assigning the right pointer to the right side of equation (second string) } Multiplication::~Multiplication() { //destructor //delete } float Multiplication::evaluate() { //completes the multiplication while reevaluating both sides through arithmetic expression return (left->evaluate() * right->evaluate()); //left and right are pointers to arithmetic Expression objects, it evaluates through that class } void Multiplication::print() { //prints the left side and then a multiply and then right side //print cout <<left<<" * "<<right<<endl; }
Java
UTF-8
2,880
4
4
[]
no_license
package com.jb.leetcode.linkedlist; import java.util.HashMap; import java.util.Map; /** * Design a data structure that follows the constraints of a Least Recently Used (LRU) * cache. * * Implement the LRUCache class: * * LRUCache(int capacity) Initialize the LRU cache with positive size capacity. * int get(int key) Return the value of the key if the key exists, otherwise return -1. * void put(int key, int value) Update the value of the key if the key exists. Otherwise, * add the key-value pair to the cache. If the number of keys exceeds the capacity from * this operation, evict the least recently used key. * * @Link https://leetcode.com/problems/lru-cache * * @author jbhushan */ public class LRUCache { class DlinkedNode{ int key; int val; DlinkedNode prev; DlinkedNode next; } /** * This method is used to add given node to the head * @param node */ private void addNode(DlinkedNode node){ node.prev = head; node.next = head.next; head.next.prev = node; head.next = node; } /** * This method is used to remove give node * @param node */ private void removeNode(DlinkedNode node){ DlinkedNode prev = node.prev; DlinkedNode next = node.next; prev.next = next; next.prev = prev; } private void moveNodeToHead(DlinkedNode node){ removeNode(node); addNode(node); } private DlinkedNode popTail(){ DlinkedNode res = tail.prev; removeNode(res); return res; } private Map<Integer, DlinkedNode> cache = new HashMap<Integer, DlinkedNode>(); int size; int capacity; DlinkedNode head; DlinkedNode tail; public LRUCache(int capacity){ this.size = 0; this.capacity = capacity; this.head = new DlinkedNode(); this.tail = new DlinkedNode(); head.next = tail; tail.prev=head; } public int get(int key){ DlinkedNode node = cache.get(key); if(node == null){ return -1; } // since it is most recently used, move to head moveNodeToHead(node); return node.val; } public void put(Integer key, Integer val){ // check if key exists or not DlinkedNode node = cache.get(key); if(node == null){ DlinkedNode newNode = new DlinkedNode(); newNode.val = val; newNode.key = key; cache.put(key, newNode); addNode(newNode); size++; //check for capacity if(size > capacity){ DlinkedNode tail = popTail(); cache.remove(tail.key); size--; } } else { node.val = val; moveNodeToHead(node); } } }
Swift
UTF-8
1,283
2.796875
3
[]
no_license
// // RatingClass.swift // ChulsaGo // // Created by Nu-Ri Lee on 2017. 7. 3.. // Copyright © 2017년 nuri lee. All rights reserved. // import UIKit class RatingClass{ static func rating(point : Int) -> String{ var rating : String = "계란"; if point < 10 { rating = NSLocalizedString("egg", comment: "egg"); }else if point < 20{ rating = NSLocalizedString("chick", comment: "chick"); }else if point < 50{ rating = NSLocalizedString("big chick", comment: "big chick"); }else if point < 100{ rating = NSLocalizedString("chicken", comment: "chicken"); }else if point < 200{ rating = NSLocalizedString("chicken ribs", comment: "chicken ribs"); }else if point < 300{ rating = NSLocalizedString("samgyetang", comment: "samgyetang"); }else if point < 400{ rating = NSLocalizedString("fried chicken", comment: "fried chicken"); }else if point < 500{ rating = NSLocalizedString("seasoned chicken", comment: "seasoned chicken"); }else{ rating = NSLocalizedString("god of the chicken", comment: "god of the chicken"); } return rating } }
Java
UTF-8
269
1.789063
2
[]
no_license
package ninja.thor.model; import lombok.Builder; import lombok.Data; @Data @Builder public class Image { private String id; private String svgPath; private String title; private float latitude; private float longitude; private double scale; }
Python
UTF-8
1,830
4.0625
4
[]
no_license
import math # Python3 program to find (a^b) % MOD # where a and b may be very large # and represented as strings. MOD = 1000000007 # https://www.geeksforgeeks.org/modulo-power-for-large-numbers-represented-as-strings/ # Returns modulo exponentiation # for two numbers represented as # long long int. It is used by # powerStrings(). Its complexity # is log(n) def powerLL(x, n): result = 1 while (n): if (n & 1): result = result * x % MOD n = int(n / 2) x = x * x % MOD return result def factor(a,b): result=1 for i in range(a,b+1): result*=i # Returns modulo exponentiation # for two numbers represented as # strings. It is used by powerStrings() def powerStrings(sa, sb): # We convert strings to number a = 0 b = 0 # calculating a % MOD for i in range(len(sa)): a = (a * 10 + (ord(sa[i]) - ord('0'))) % MOD # calculating b % (MOD - 1) for i in range(len(sb)): b = (b * 10 + (ord(sb[i]) - ord('0'))) % (MOD - 1) # Now a and b are long long int. # We calculate a^b using modulo # exponentiation return powerLL(a, b) def modPow(b, e, m): r = 1 b %= m while e > 0: if e % 2 == 1: r = (r * b) % m e = math.floor(e / 2) b = (b ** 2) % m return r # Driver code # As numbers are very large # that is it may contains upto # 10^6 digits. So, we use string. t = int(input()) for i in range(t): a, b, c = map(int, input().split()) # binom = math.factorial(b)/(math.factorial(c)*math.factorial(b-c)) if a != 1: binom = math.comb(b, c) print(powerStrings(str(a), str(binom))) else: print(1)
PHP
UTF-8
2,697
2.546875
3
[]
no_license
<?php /** * Created by PhpStorm. * User: zzc * Date: 2015/7/6 * Time: 13:21 * @新需求,创建聊天分组 */ class Api_Livechat_Group_AddMember extends Api { /** * * 传入参数 * * members 新增加的成员 array( * '用户的ID'=>array( * 'account_id'=> //用户的id * 'username'=> 用户名称 * ) * ) * group_id 分组的id * */ static function handleAddMember($args) { $request = Func_Input::filter(array( 'members' => 'array', //新增的成员 'group_id' => 'int', //分组的ID ), $args); if (empty($request['group_id']) || empty($request['members'])) { return Api::request('error', '', '缺少参数或者参数不正确,请检查参数合法性'); } $request['group_id'] = Data_Mysql_Table_LiveChat_Group::convertFromAccountId($request['group_id']); $is_exist = Data_Mysql_Table_LiveChat_Group::select('id,members', array( 'id =?' => $request['group_id'])); $newMembers = array(); foreach ($request['members'] as $v) { if (!empty($v['account_id'])) { $newMembers[$v['account_id']] = array( 'account_id' => $v['account_id'], 'username' => $v['username'], ); } } if (!empty($is_exist[0]['id'])) { $members = json_decode($is_exist[0]['members'], true); $newAll = array(); foreach ($members as $k => $val) { if (!empty($val['account_id'])) { $newAll[$val['account_id']] = $val; } } foreach ($newMembers as $k => $val) { $newAll[$val['account_id']] = $val; } $members_total = count($newAll); $status = Data_Mysql_Table_LiveChat_Group::update(array('id =?' => $request['group_id']), array( 'members' => $newAll, 'members_total' => $members_total )); if (!empty($status[0])) { //清除群头像缓存 @unlink(Core::$paths['root'] . "upload/group/" . $request['group_id'] . ".jpg"); return Api::request('success', '', '成员添加成功'); } return Api::request('error', '', '成员添加失败'); } else { return Api::request('error', '', '不存在这个分组'); } } }
Markdown
UTF-8
2,166
2.765625
3
[]
no_license
# ASPNET1_inl-mningsuppgift The main project I did for the ASP.NET 1 course (unfinished admin functionality) Description: (SWE) Inlämningsuppgift 2: Skapa webbsajt för Tomasos pizzeria Beskrivning Uppgiften handlar om att skapa en webblösning i ASP.NET MVC för en pizzeria, Tomasos Pizzeria. Alla uppgifter skall sparas och hämtas från den färdiga databas som ni får. Din uppgift är att bygga denna lösning med hjälp av det vi gått igenom under lektionerna. Där det inte finns några klara riktlinjer kan du själv välja hur din lösning skall se ut. Krav för att lösningen skall bli godkänd: - Skall bestå av en enhetlig layout som används i alla vyer. Skall finnas en gemensam navigering för att navigera mellan olika sidor. Ni skall använda CSS för formatteringar av färg, typsnitt, fonter och liknande. - Kunden skall kunna skapa ett användarkonto. Det skall finnas ett registreringsformulär där kunden lägger in sitt namn och övriga kunduppgifter. Där skall det också registreras ett användarnamn och ett lösenord. Dessa uppgifter skall sedan kunna sparas ned i databasen. - Validering måste finnas på alla fält där det behövs. - Det skall finnas ett inloggningsformulär där kunden skall kunna logga in med användarnamn och lösenord. Inloggningen skall verifieras mot databasen. När kunden sedan har loggat in skall denne ha möjlighet att ändra sina egna kontaktuppgifter och spara ned dessa i databasen. - Innehålla ett formulär för beställning av pizzor och andra typer av maträtter. Beställningsformuläret skall innehålla en meny med pizzor, där ingredienser och pris för varje pizza visas. Ingredienserna måste hämtas från databasen dvs de ingredienser som är kopplade till maträtten skall visas. Här finns även andra typer av maträtter tex pasta och sallader. - Kunden skall kunna beställa ett antal maträtter och beställningen skall kunna sparas i databasen. Detta kan antingen byggas som en webbshop eller som en direkt beställningsfunktion med en beställa-knapp. Kunden måste logga in först för att kunna skicka en beställning. - Entity framework skall användas för modellen.
Java
UTF-8
1,191
2.671875
3
[]
no_license
package pageObject.mmjtraine.businessobject.useresfacade; public class UserHelper { private IUsers admin; private IUsers manager; private IUsers shipper; public UserHelper(){ admin = new Admin(); manager = new Manager(); shipper = new Shipper(); } public String readAdminUserEmail() { return admin.readEmail(); } public String readManagerUserEmail() { return manager.readEmail(); } public String readShipperUserEmail() { return shipper.readEmail(); } public String readAdminUserPassword() { return admin.readPassword(); } public String readManagerUserPassword() { return manager.readPassword(); } public String readShipperUserPassword() { return shipper.readPassword(); } public static void main(String[] args) { UserHelper userHelper = new UserHelper(); userHelper.readAdminUserEmail(); userHelper.readManagerUserEmail(); userHelper.readShipperUserEmail(); userHelper.readAdminUserPassword(); userHelper.readManagerUserPassword(); userHelper.readShipperUserPassword(); } }
Java
UTF-8
1,051
2.75
3
[]
no_license
/* * @author Daniel Amarante - 13201876-3 - daniel.amarante2@gmail.com * @author Matthias Nunes - 08105058-5 - matthiasnunes@gmail.com * @author Pedro Kühn - 10200237-5 - pedrohk@gmail.com */ import java.util.ArrayList; import java.util.Iterator; public class TabSimb { private ArrayList<TS_entry> lista; public TabSimb( ) { lista = new ArrayList<TS_entry>(); } public void insert( TS_entry nodo ) { lista.add(nodo); } public void listar() { int cont = 0; System.out.println("\n\nListagem da tabela de simbolos:\n"); for (TS_entry nodo : lista) { System.out.println(nodo); } } public TS_entry pesquisa(String umId, String escopo) { for (TS_entry nodo : lista) { if (nodo.getEscopo().equals(escopo) || nodo.getEscopo().equals("")) { if (nodo.getId().equals(umId)) { return nodo; } } } return null; } public ArrayList<TS_entry> getLista() {return lista;} }
C++
UTF-8
568
2.75
3
[]
no_license
#include<iostream> #include<stdio.h> #include<conio.h> #include<string.h> using namespace std; int main() { char a[9]="01111110",data[100],stuff[110]="",send[130]=""; int i,n,j,count=0; cout<<"Enter the data to be sent:"; cin>>data; n=strlen(data); for(i=0,j=0;i<n;i++) { stuff[j++]=data[i]; if(data[i]=='1') count++; else count=0; if(count==5) { stuff[j++]='0'; count=0; } } cout<<"The stuffed data is: "<<stuff; strcat(send,a); strcat(send,stuff); strcat(send,a); cout<<"\n\nThe data transmitted is: "<<send; getch(); }
Markdown
UTF-8
7,363
2.640625
3
[]
no_license
# TensorFlow-Keras ここでは、TensorFlowとKerasをpipで導入して実行する手順を説明します。具体的には、TensorFlowとKerasを導入して実行する手順と、TensorFlow、KerasとHorovodを導入して分散学習を実行する手順を示します。 ## TensorFlow-Kerasの単体実行 {#using} ### 前提 {#precondition} - `grpname`はご自身のABCI利用グループ名に置き換えてください - [Python仮想環境](/06/#python-virtual-environments){:target="python-virtual-enviroments"}はインタラクティブノードと各計算ノードで参照できるよう、[ホーム領域](/04/#home-area){:target="home-area"}または[グループ領域](/04/#group-area){:target="group-area"}に作成してください - サンプルプログラムはインタラクティブノードと各計算ノードで参照できるよう、[ホーム領域](/04/#home-area){:target="home-area"}または[グループ領域](/04/#group-area){:target="group-area"}に保存してください ### 導入方法 {#installation} [venv](/06/#venv){:target="python_venv"}モジュールでPython仮想環境を作成し、作成したPython仮想環境へTensorFlowとKerasを[pip](/06/#pip){:target="pip"}で導入する手順です。 ``` [username@es1 ~]$ qrsh -g grpname -l rt_G.small=1 -l h_rt=1:00:00 [username@g0001 ~]$ module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 [username@g0001 ~]$ python3 -m venv ~/venv/tensorflow-keras [username@g0001 ~]$ source ~/venv/tensorflow-keras/bin/activate (tensorflow-keras) [username@g0001 ~]$ pip3 install --upgrade pip setuptools (tensorflow-keras) [username@g0001 ~]$ pip3 install tensorflow-gpu==1.15 keras ``` 次回以降は、次のようにモジュールの読み込みとPython仮想環境のアクティベートだけでTensorFlow、Kerasを使用できます。 ``` [username@g0001 ~]$ module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 [username@g0001 ~]$ source ~/venv/tensorflow-keras/bin/activate ``` ### 実行方法 {#run} TensorFlowサンプルプログラム `mnist_cnn.py` 実行方法をインタラクティブジョブとバッチジョブそれぞれの場合で示します。 **インタラクティブジョブとして実行** ``` [username@es1 ~]$ qrsh -g grpname -l rt_G.small=1 -l h_rt=1:00:00 [username@g0001 ~]$ module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 [username@g0001 ~]$ source ~/venv/tensorflow-keras/bin/activate (tensorflow-keras) [username@g0001 ~]$ git clone https://github.com/keras-team/keras.git (tensorflow-keras) [username@g0001 ~]$ python3 keras/examples/mnist_cnn.py ``` **バッチジョブとして実行** 次のジョブスクリプトを `run.sh` ファイルとして保存します。 ``` #!/bin/sh #$ -l rt_G.small=1 #$ -j y #$ -cwd source /etc/profile.d/modules.sh module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 source ~/venv/tensorflow-keras/bin/activate git clone https://github.com/keras-team/keras.git python3 keras/examples/mnist_cnn.py deactivate ``` バッチジョブ実行のため、ジョブスクリプト `run.sh` をqsubコマンドでバッチジョブとして投入します。 ``` [username@es1 ~]$ qsub -g grpname run.sh Your job 1234567 ('run.sh') has been submitted ``` ## TensorFlow + Horovod {#using-with-horovod} ### 前提 {#precondition-with-horovod} - `grpname`はご自身のABCI利用グループ名に置き換えてください - [Python仮想環境](/06/#python-virtual-environments){:target="python-virtual-enviroments"}はインタラクティブノードと各計算ノードで参照できるよう、[ホーム領域](/04/#home-area){:target="home-area"}または[グループ領域](/04/#group-area){:target="group-area"}に作成してください - サンプルプログラムはインタラクティブノードと各計算ノードで参照できるよう、[ホーム領域](/04/#home-area){:target="home-area"}または[グループ領域](/04/#group-area){:target="group-area"}に保存してください ### 導入方法 {#installation-with-horovod} [venv](/06/#venv){:target="_python_venv"}モジュールでPython仮想環境を作成し、作成したPython仮想環境へTensorFlow、KerasとHorovodを[pip](/06/#pip){:target="pip"}で導入する手順です。 ``` [username@es1 ~]$ qrsh -g grpname -l rt_G.small=1 -l h_rt=1:00:00 [username@g0001 ~]$ module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 nccl/2.5/2.5.6-1 openmpi/2.1.6 gcc/7.4.0 [username@g0001 ~]$ python3 -m venv ~/venv/tensorflow-keras+horovod [username@g0001 ~]$ source ~/venv/tensorflow-keras+horovod/bin/activate (tensorflow-keras+horovod) [username@g0001 ~]$ pip3 install --upgrade pip setuptools (tensorflow-keras+horovod) [username@g0001 ~]$ pip3 install tensorflow-gpu==1.15 keras (tensorflow-keras+horovod) [username@g0001 ~]$ HOROVOD_WITH_TENSORFLOW=1 HOROVOD_GPU_OPERATIONS=NCCL HOROVOD_NCCL_HOME=$NCCL_HOME pip3 install --no-cache-dir horovod ``` 次回以降は、次のようにモジュールの読み込みとPython仮想環境のアクティベートだけでTensorFlow、KerasとHorovodを使用できます。 ``` [username@g0001 ~]$ module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 nccl/2.5/2.5.6-1 openmpi/2.1.6 gcc/7.4.0 [username@g0001 ~]$ source ~/venv/tensorflow-keras+horovod/bin/activate ``` ### 実行方法 {#run-with-horovod} Horovodを利用するTensorFlowサンプルプログラム `keras_mnist.py` で分散学習する方法をインタラクティブジョブとバッチジョブそれぞれの場合で示します。 **インタラクティブジョブとして実行** この例では、インタラクティブノードの4つのGPUを利用して分散学習します。 ``` [username@es1 ~]$ qrsh -g grpname -l rt_G.large=1 -l h_rt=1:00:00 [username@g0001 ~]$ module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 nccl/2.5/2.5.6-1 openmpi/2.1.6 gcc/7.4.0 [username@g0001 ~]$ source ~/venv/tensorflow-keras+horovod/bin/activate [username@g0001 ~]$ git clone -b v0.20.0 https://github.com/horovod/horovod.git [username@g0001 ~]$ mpirun -np 4 -map-by ppr:4:node python3 horovod/examples/keras_mnist.py ``` **バッチジョブとして実行** この例では、計8つのGPUを利用して分散学習します。計算ノード2台を使用し、計算ノード1台あたり4つのGPUを使用しています。 次のジョブスクリプトを `run.sh` ファイルとして保存します。 ``` #!/bin/sh -x #$ -l rt_F=2 #$ -j y #$ -cwd source /etc/profile.d/modules.sh module load python/3.6/3.6.5 cuda/10.0/10.0.130.1 cudnn/7.6/7.6.5 nccl/2.5/2.5.6-1 openmpi/2.1.6 gcc/7.4.0 source ~/venv/tensorflow-keras+horovod/bin/activate git clone -b v0.20.0 https://github.com/horovod/horovod.git NUM_NODES=${NHOSTS} NUM_GPUS_PER_NODE=4 NUM_GPUS_PER_SOCKET=$(expr ${NUM_GPUS_PER_NODE} / 2) NUM_PROCS=$(expr ${NUM_NODES} \* ${NUM_GPUS_PER_NODE}) MPIOPTS="-np ${NUM_PROCS} -map-by ppr:${NUM_GPUS_PER_NODE}:node" mpirun ${MPIOPTS} python3 horovod/examples/keras_mnist.py deactivate ``` バッチジョブ実行のため、ジョブスクリプト `run.sh` をqsubコマンドでバッチジョブとして投入します。 ``` [username@es1 ~]$ qsub -g grpname run.sh Your job 1234567 ('run.sh') has been submitted ```
C#
UTF-8
6,106
2.546875
3
[ "MIT" ]
permissive
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; namespace SATInterface { internal class OrExpr : BoolExpr { internal readonly BoolExpr[] elements; private OrExpr(BoolExpr[] _elems) { elements = _elems; } internal static BoolExpr Create(params BoolExpr[] _elems) => Create(_elems.AsEnumerable()); internal static BoolExpr Create(IEnumerable<BoolExpr> _elems) { var res = new HashSet<BoolExpr>(); foreach (var es in _elems) if (ReferenceEquals(es, null)) throw new ArgumentNullException(); else if (ReferenceEquals(es, Model.True)) return Model.True; else if (es is OrExpr oe) foreach (var e in oe.elements) res.Add(e); else if (es is AndExpr ae) res.Add(ae.Flatten()); else if (!ReferenceEquals(es, Model.False)) res.Add(es); //if (!(largestAnd is null)) //{ // var orExprs = new BoolExpr[largestAnd.elements.Length]; // for (var j = 0; j < orExprs.Length; j++) // orExprs[j] = OrExpr.Create(res.Append(largestAnd.elements[j])); // return AndExpr.Create(orExprs); //} //TODO find fast way to solve set cover approximately for CSE //if (res.Count == 0) // return Model.False; //if (res.Count == 1) // return res.Single(); //var model = res.First().EnumVars().First().Model; //for (var i = 0; i < res.Count; i++) // for (var j = i + 1; j < res.Count; j++) // for (var k = j + 1; k < res.Count; k++) // { // var ei = res.ElementAt(i); // var ej = res.ElementAt(j); // var ek = res.ElementAt(k); // if (model.ExprCache.TryGetValue(new OrExpr(new[] { ei, ej, ek }), out var lu) && lu.VarCount <= 1) // { // res.Remove(ei); // res.Remove(ej); // res.Remove(ek); // res.Add(lu); // Console.Write("3"); // } // } //for (var i = 0; i < res.Count; i++) // for (var j = i + 1; j < res.Count; j++) // { // var ei = res.ElementAt(i); // var ej = res.ElementAt(j); // if (model.ExprCache.TryGetValue(new OrExpr(new[] { ei, ej }), out var lu) && lu.VarCount <= 1) // { // res.Remove(ei); // res.Remove(ej); // res.Add(lu); // Console.Write("2"); // } // } if (res.Count == 0) return Model.False; if (res.Count == 1) return res.Single(); if (res.OfType<NotExpr>().Any(ne => res.Contains(ne.inner))) return Model.True; var ret = new OrExpr(res.ToArray()); var model = ret.EnumVars().First().Model; if (model.Configuration.CommonSubexpressionElimination) { if (model.ExprCache.TryGetValue(ret, out var lu)) return lu; model.ExprCache[ret] = ret; } return ret; } public override string ToString() => "(" + string.Join(" | ", elements.Select(e => e.ToString()).ToArray()) + ")"; private BoolExpr? flattenCache; public override BoolExpr Flatten() { if (!(flattenCache is null)) return flattenCache; var model = EnumVars().First().Model; if (model.Configuration.CommonSubexpressionElimination && model.ExprCache.TryGetValue(this, out var lu) && lu.VarCount <= 1) return flattenCache = lu; flattenCache = model.AddVar(); model.AddConstr(OrExpr.Create(elements.Append(!flattenCache))); foreach (var e in elements) model.AddConstr(!e | flattenCache); if (model.Configuration.CommonSubexpressionElimination) { model.ExprCache[this] = flattenCache; model.ExprCache[!this] = !flattenCache; } return flattenCache; } internal override IEnumerable<BoolVar> EnumVars() { foreach (var e in elements) foreach (var v in e.EnumVars()) yield return v; } public override bool X => elements.Any(e => e.X); public override int VarCount => elements.Length; public override bool Equals(object _obj) { var other = _obj as OrExpr; if (ReferenceEquals(other, null)) return false; if (elements.Length != other.elements.Length) return false; foreach (var a in elements) if (!other.elements.Contains(a)) return false; foreach (var a in other.elements) if (!elements.Contains(a)) return false; return true; } private int hashCode; public override int GetHashCode() { if (hashCode == 0) { hashCode = GetType().GetHashCode(); //deliberatly stupid implementation to produce //order-independent hashcodes foreach (var e in elements) hashCode += HashCode.Combine(e); if (hashCode == 0) hashCode++; } return hashCode; } } }
C#
UTF-8
1,050
3.9375
4
[]
no_license
using System; using System.Collections.Generic; using System.IO; using System.Text; class Solution { static class StringHelper { public static string ReverseString(string s) { char[] arr = s.ToCharArray(); Array.Reverse(arr); return new string(arr); } } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); while(n > 0){ bool flag = true; string s = Console.ReadLine(); string sReverse = StringHelper.ReverseString(s); for(int j = 1; j < s.Length; j++){ if(Math.Abs(s[j] - s[j - 1]) != Math.Abs(sReverse[j] - sReverse[j - 1])) { flag = false; break; } } if(flag){ Console.WriteLine("Funny"); } else { Console.WriteLine("Not Funny"); } n--; } } }
Python
GB18030
7,715
2.578125
3
[]
no_license
from Tkinter import * from tkMessageBox import * import sys,json import urllib,urllib2 from os import path from urllib import quote from urllib import unquote import re import sys class EntryDemo( Frame): """ Demonstrate Entrys and Envent Building""" def __init__( self ): Frame.__init__(self) self.pack(expand=YES,fill = BOTH) self.master.title("please input keywords and url here") self.master.geometry("800x600") #width X length #Entry Demo self.frame1 = Frame(self) self.frame1.pack( pady = 5 ) #ֱ self.text1 = Entry(self.frame1, name="text1") #frame1 self.text1.bind("<Return>",self.showContents ) self.text1.insert(INSERT, "Enter keywords here") self.text1.bind("<Enter>", self.textEnter) #¼: self.text1.pack(side=LEFT, padx=5) self.text2 = Entry(self.frame1, name="text2") self.text2.insert(INSERT, "Enter url here") self.text2.bind("<Return>",self.showContents ) self.text2.bind("<Enter>", self.textEnter) #¼: self.text2.pack(side=LEFT,padx=5) self.frame2=Frame(self) self.frame2.pack(pady=5) self.text3=Entry(self.frame2, name="text3") self.text3.insert(INSERT,"Uneditable text field") #button Demo self.frame3= Frame(self) self.frame3.pack(pady = 5) self.plainButton=Button(self.frame3, text="submit",\ command= self.pressedPlain) self.plainButton.bind("<Enter>", self.rolloverEnter) #¼: self.plainButton.bind("<Leave>", self.rolloverLeave) #¼뿪 self.plainButton.pack(side=LEFT,padx=5, pady=5) #showlebal self.frame4= Frame(self) self.frame4.pack(pady = 5) self.conclusion=Text(self.frame4) #self.conclusion.wrap(WORD) self.conclusion.pack() def pressedPlain(self): message = "keywords=",self.text1.get(),"url=",self.text2.get() self.conclusion.delete(0.0, END) #showinfo("Message",message) dic = self.getret(self.text1.get(),self.text2.get()) #conclusion conclusion = u'trace conclusion:' if dic['conclusion'] is not None: for i,val in enumerate(dic['conclusion']): print conclusion,'-',val conclusion="".join([conclusion,val]) else : conclusion="".join([conclusion,'debug does not return the conclusion','\t']) line = '\n model\t\tCheck-list\t\tresult\t\t\tdetail' conclusion="".join([conclusion,line]) #record ac_tag='' bc_tag='' bs_tag='' buildMissModule_tag='' spiderMissModule_tag='' if dic['record'] is not None: res = self.recordClassify(dic['record']) if res[0]is not None: for i,val in enumerate(res[0]): ac_tag="".join([val,'\n']) if res[1]is not None: for i,val in enumerate(res[1]): bc_tag="".join([val,'\n']) if res[2]is not None: for i,val in enumerate(res[2]): bs_tag="".join([val,'\n']) if res[3]is not None: for i,val in enumerate(res[3]): buildMissModule_tag="".join([val,'\n']) #print '+++'*5,buildMissModule_tag if res[4]is not None: for i,val in enumerate(res[4]): spiderMissModule_tag="".join([val,'\n']) #print buildMissModule_tag record="".join([spiderMissModule_tag,buildMissModule_tag,bs_tag,bc_tag,ac_tag,'\n']) conclusion="".join([conclusion,record.decode('utf8')]) else: conclusion="".join([conclusion,'\nno detail']) self.conclusion.insert(INSERT,conclusion) conclusion='' def rolloverEnter(self,event): event.widget.config(relief=GROOVE) def rolloverLeave(self,event): event.widget.config(relief=RAISED) def textEnter(self,event): #print event.widget.get() if (event.widget.get() == 'Enter keywords here') or (event.widget.get() == 'Enter url here' ) : event.widget.delete(0,20) def showContents(self, event): theName=event.widget.winfo_name() theContents=event.widget.get() showinfo("Message", theName +":"+ theContents) def getret(self,keywords,url_test): url_0=''' http://debug0.baidu.com:8088/frame/frame.php?input=%7B%22url%22%3A%22''' url_test=quote(url_test) url_1 = '''%22%2C%22link%22%3A%22http%3A%2F%2Fdebug0.baidu.com%3A9000%2Fmsg%2Fhome%2Fservice%3Fwd%3D''' url_2 = '''%26lm%3D0%26cl%3D3%26ct%3D0%26info%3D2%26lang%3Dcn%26ie%3Dutf-8%26env%3Ddebug0.baidu.com%253A9100%26ac_cl%3D3%26rn%3D10%26level%3D4128799%26rebuildu%3D%255B%255D%26tn%3Dbaidudata%22%2C%22name%22%3A%22urlmiss%22%7D&cb=caseflow.urlmiss_finish ''' keywords=quote(keywords.encode('utf8')) url = "".join([url_0,url_test,url_1,keywords, url_2]) #print url ret = urllib.urlopen(url) ret_data = ret.read() #print ret_data ret_data = ret_data[24:-1] #print ret_data json.dumps(ret_data) dic = json.loads(ret_data,encoding='utf8') #print dic,'\n' return dic def recordClassify(self,listrecord): rePath = './/reDataPath.txt' with open(rePath) as re_data: reStr = re_data.readlines() ac=[] bc=[] bs=[] buildMissModule=[] spiderMissModule=[] for v in range(0,len(listrecord)): #print listrecord[v] listrecord[v] listrecord_i = listrecord[v].replace(" ","").replace(" ","").strip() for i,val in enumerate(reStr): val = val.split('|') rt = val[0].replace(" ","").replace(" ","").strip() rt=unicode(rt,'utf8') pattern = re.compile(rt) match = pattern.match(listrecord_i) if match: if val[3] == 'ac\n' : str_ac = "".join(['\nac\t\t',val[1],'\t\t',val[2],'\t\t\t',val[0]]) ac.append(str_ac) elif val[3] == 'bc\n' : str_bc = "".join(['\nbc\t\t',val[1],'\t\t',val[2],'\t\t\t',val[0]]) bc.append(str_bc) elif val[3] == 'bs\n' : str_bs = "".join(['\nbs\t\t',val[1],'\t\t',val[2],'\t\t\t',val[0]]) bs.append(str_bs) elif val[3] == 'buildMissModule\n' : str_buildMissModule = "".join(['\nbuildMissModule\t\t',val[1],'\t\t',val[2],'\t\t\t',val[0]]) buildMissModule.append(str_buildMissModule) elif val[3] == 'spiderMissModule\n' : str_spiderMissModule = "".join(['\nspiderMissModule\t\t',val[1],'\t\t',val[2],'\t\t\t',val[0]]) spiderMissModule.append(str_spiderMissModule) else : pass ret_list=[ac,bc,bs,buildMissModule,spiderMissModule] return ret_list def main(): EntryDemo().mainloop() if __name__=="__main__": print 'start' main()
Ruby
UTF-8
1,795
3.1875
3
[]
no_license
dir = File.dirname(__FILE__) require dir + '/../init' class Bobo include Glyde::HasType # # N.B. Type variable. Values' types must be same OR # share an ancestor more specific than Object. # type :OtherHash do {Symbol=>String} end sig do :a * OtherHash >> :a * OtherHash end def self.class_method(a, h={}) puts "in class_method" [a, h] end # - instance - sig_attr_accessor :my_int do Integer end def initialize self.my_int = 1 end sig do [Integer] >> String end def takes_int_array(ints) ints.join(',') end # For making type synonyms. type :MyKey do String |Symbol end type :MyVal do Integer|String end type :MyHash do {MyKey => MyVal} end sig do MyKey * MyVal * MyHash >> MyHash end def add_to_hash(k, v, hash) hash[k] = v hash end sig do Integer * :a.splat >> OtherHash end def foo(int, *args) puts my_int {:args => args.inspect} end sig do (Integer|nil) >> () end def bar(a) puts 'in bar' puts a end end class A def all b = Bobo.new b.bar(1) puts b.takes_int_array([1,2,3]) # puts b.takes_int_array([-2,-1,0,1,2,:three,4,5,6,7,8,9]) # h = {'a' => 1, 'b' => 2.3} h = {'a' => 1, 'b' => 2} puts b.add_to_hash('c', 3, h).inspect puts Bobo.class_method(1, {:a => 'foo'}).inspect b = Bobo.new puts b.foo(3, 'foo', :foo, 'bar').inspect b.bar(nil) puts puts puts "Bobo's CALLED signed methods: " puts Bobo.called_signed_methods.inspect puts Bobo.uncalled_signed_methods.inspect puts puts "actual types: " puts Glyde::HasType.actual_types puts puts "callers: " puts Glyde::HasType.callers end end Glyde::HasType.turn_off a = A.new a.all Glyde::HasType.turn_on a = A.new a.all
Shell
UTF-8
421
3.421875
3
[]
no_license
#!/bin/bash COMMIT_MESSAGE=$(git log -1 --pretty=%B) if [[ $COMMIT_MESSAGE == *"[pr]"* ]] then echo "[pr] found - auto creating pull request" BRANCH_NAME=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') hub pull-request --no-edit --base=master --head=${BRANCH_NAME} > pull_request_url.txt chmod +x ./create_issue.sh && ./create_issue.sh else echo "[pr] not found - skipping auto pull request creation" fi
Java
UTF-8
446
2.015625
2
[ "Apache-2.0" ]
permissive
package io.groundhog.replay; import com.google.common.util.concurrent.Service; /** * @author Michael Olague * @since 1.0 */ public interface RequestDispatcher extends Service { /** * The number of milliseconds that the dispatcher can skew from real-time, before warnings are logged. */ public static final int SKEW_THRESHOLD_MILLIS = 250; void queue(DelayedUserAgentRequest request) throws InterruptedException; void clearQueue(); }
Java
UTF-8
1,482
2.71875
3
[]
no_license
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package db; import server.*; import java.rmi.*; import java.rmi.registry.*; import java.util.Arrays; import java.net.MalformedURLException; /** * Concrete implementation of the <code>Connector</code> interface, used to * connect to a remote database. Acts as a client. * *@author Matthew Farley 90045985 *09 October 2013 *@version 1.0 */ public class NetworkConnector implements Connector { private String path; private int port; private String dbName; private RemotableDB dbStub; //Use the Interface Type RemotableDB private String fullName; /** * Creates a new <Code>LocalConnector</code> object * * @param path * @param port * @throws RemoteException */ public NetworkConnector(String path, int port) throws RemoteException, NotBoundException, MalformedURLException{ this.path = path; //local path is "rmi://127.0.0.1/" this.port = port; dbName = "remoteDB"; fullName = path + dbName; Registry registry = LocateRegistry.getRegistry(port); System.out.println(Arrays.toString(registry.list()));// debugging dbStub = (RemotableDB)Naming.lookup(fullName); } /** * * @return A server database object set with a path and port */ @Override public RemotableDB getDatabase(){ return this.dbStub; } }
Java
UTF-8
775
3.703125
4
[]
no_license
package array; import java.util.Scanner; public class EvenOdd { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter how many value you have"); int n = sc.nextInt(); int ar[] = new int[n]; System.out.println("Enter " + n + " Integer Value"); for (int i = 0; i < n; i++) { ar[i] = sc.nextInt(); } int c[] = countEO(ar); System.out.println("Number of even number " + c[0]); System.out.println("Number of odd number " + c[1]); } static int[] countEO(int[] ar) { int count[] = new int[2]; for (int i = 0; i < ar.length; i++) { /* * if(ar[i]%2==0) { count[0]++; * * } else count[1]++; } */ count[ar[i] % 2]++; } return count; } }
Python
UTF-8
417
2.640625
3
[]
no_license
class Solution: def thirdMax(self, nums: [int]) -> int: dummy = [float('-inf'), float('-inf'), float('-inf')] for num in nums: if num not in dummy: if num > dummy[0]: dummy = [num, dummy[0], dummy[1]] elif num > dummy[1]: dummy = [dummy[0], num, dummy[1]] elif num > dummy[2]: dummy = [dummy[0], dummy[1], num] return max(nums) if float('-inf') in dummy else dummy[2]
Java
UTF-8
321
1.804688
2
[]
no_license
package com.providesupport.monitoring.dao; import com.providesupport.monitoring.entity.WebResource; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; public interface WebResourceRepository extends JpaRepository<WebResource, Long> { List<WebResource> findAllByUrl(String url); }
Java
UTF-8
1,525
1.890625
2
[]
no_license
package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; public class MobileReg extends AppCompatActivity { public Button button0, button1; public CheckBox frgtpassclick; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /*go to next activity*/ button0 = findViewById(R.id.button0); button0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(MobileReg.this,OTPver.class); startActivity(i); } }); button1 = findViewById(R.id.button1); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(MobileReg.this,Homepage.class); startActivity(i); } }); frgtpassclick = findViewById(R.id.frgtpassclick); frgtpassclick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(MobileReg.this,ForgotPassword.class); startActivity(i); } }); } }
Java
UTF-8
219
1.828125
2
[]
no_license
package br.edu.ifnmg.arinos.systemvendas.util.excecao; /** * * @author guest-yfceG9 */ public class ErroNegocio extends Exception{ public ErroNegocio(String message) { super(message); } }
Java
UTF-8
140
1.609375
2
[]
no_license
package com.xrq.rabbitmq.mapper; import com.xrq.rabbitmq.entity.Order; public interface OrderMapper { int insert(Order record); }
Markdown
UTF-8
6,909
2.921875
3
[]
no_license
title=Introducing GCC-Bridge: A C/Fortran compiler targeting the JVM date=2016-01-31 type=post status=published author=Alex Bertram lang=en excerpt=GCC-Bridge is a C/Fortran compiler targeting the Java Virtual Machine (JVM) that makes it possible for Renjin to run R packages that include &lsquo;native&rsquo; C and Fortran code without sacrificing platform independence. ~~~~~~ In this post, I wanted to finally give a proper introduction to GCC-Bridge, a C/Fortran compiler targeting the Java Virtual Machine (JVM) that makes it possible for Renjin to run R packages that include "native" C and Fortran code without sacrificing platform independence. ## Motivation Supporting R packages with native code is a big deal: 48% of CRAN's 33 MLOC of code is native code. And so while our ultimate goal is to allow users to write fast R code without falling back to another language, if we're to be serious about running existing R packages, then we need a solution for the existing native code base. <figure> <table> <thead> <tr> <th align="left">Repository</th> <th align="right">R</th> <th align="right">C</th> <th align="right">C++</th> <th align="right">Fortran</th> </tr> </thead> <tbody> <tr> <th align="left">CRAN</th> <td align="right">17.2</td> <td align="right">8.8</td> <td align="right">5.2</td> <td align="right">1.8</td> </tr><tr> <th align="left">BioConductor</th> <td align="right">2.5</td> <td align="right">1.8</td> <td align="right">1.7</td> <td align="right">0.02</td> </tr> </tbody> </table> <figcaption>Millions of lines of code (MLOC), excluding blank lines, within the latest available package version. Source: <a href="http://packages.renjin.org/source">packages.renjin.org</a> </figcaption> </figure> But we also wanted a solution that preserved Renjin's advantages over GNU R. If we were to try to use JNI to load platform-specific native libraries, then we would inherit all of the deployment headaches that we set to solve in building Renjin on the JVM, and loose the ability to run on Google AppEngine and other sandboxed environments. More troubling, the widespread use of global variables in package native code would severely complicate Renjin's auto parallization strategies, and prevent users from running multiple, concurrent Renjin sessions in the same JVM process. For these reasons, we set out to build GCC-Bridge, a toolchain that could compile C, C++, and Fortran sources to pure Java bytecode. ## Bridging GCC and the JVM GCC-Bridge, as its name implies, builds on the GNU Compiler Collection (GCC), which has a modular structure designed to support multiple input languages, including C, C++, and Fortran, and multiple backends targeting, for example, x86, ARM, MIPs, etc. GCC achieves this small miracle by reducing all input languages into a common, simple intermediate language called [Gimple](https://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html). GCC performs most of its optimizations on Gimple, before lowering it even further to another intermediate language called the Register Transfer Language (RTL), which is then handed over to the backends to generate actual machine instructions. For us, Gimple is also a terrific starting point for a compiler targeting the JVM. Consider a simple C function which sums an array of double-precision floating point: ![Side-by-side comparison of C and Gimple, lightly stylized.](/assets/img/gcc-gimple.svg) All the complexities of C and Fortran are reduced to a simple list of statements, with a small number of operations. This is terrific, because I really, really, didn't want to have to learn Fortran! GCC-Bridge consists of a [small plugin](https://github.com/bedatadriven/renjin/blob/38ffa3833163363fc513c23eda7ebe2dcb75643a/tools/gcc-bridge/gcc-plugin/src/main/c/plugin.c) for GCC itself, which dumps the optimized gimple out to a JSON file, one per source file, and a compiler, a Java program which compiles the json-encoded Gimple files to Java class files, using the ASM bytecode library. ![High level Overview of GCC and GCC-Bridge](/assets/img/renjin-gcc.svg) Note that we're not compiling to the Java *language*. Like Scala or Clojure, we're targeting the Java *Virtual Machine*, the virtual machine original designed for Java but that has its own standard instruction set. ## Emulating the GNU R C API GNU R provides several methods for interfacing with native code from R. The simplest of these methods, the so-called .C and .Fortran interfaces, simply pass the R vectors as double-precision or integer arrays to C or Fortran functions, which might look like this: ```c void kmeans_Lloyd(double *x, int *pn, int *pp, double *centers, int *pk, int *cl, int *pmaxiter, int *nc, double *wss); ``` Renjin has supported this interface for some time, but starting with version 0.8.x released at the end of last year, we now support the .Call interface as well, which involves passing pointers to GNU R internal `SEXPREC` structures. The great thing about the GCC-Bridge tool chain is that it gives us the chance to play with the input sources before compiling them. We use this capability to map all references to the `SEXPREC` type to Renjin's own Java interface `org.renjin.sexp.SEXP`, and link all calls to the internal GNU R API to [Java methods](https://github.com/bedatadriven/renjin/blob/master/tools/gnur-runtime/src/main/java/org/renjin/gnur/api/Rinternals.java), initially [generated](https://github.com/bedatadriven/renjin/blob/master/tools/gnur-compiler/generateStubs.groovy) from GNU R's own header files. ## Kicking the Tires GCC-Bridge is an important part of the Renjin toolchain for GNU R packages, but it can also be used independently of Renjin. I've put together an example on [bedatadriven/gcc-bridge-example](https://github.com/bedatadriven/gcc-bridge-example) that compiles a [few functions](https://github.com/bedatadriven/gcc-bridge-example/blob/master/src/main/c/pnorm.c) from R's nmath library and then calls the compiled functions [from java](https://github.com/bedatadriven/gcc-bridge-example/blob/master/src/test/java/org/renjin/gcc/example/NormalDistTest.java). You can fork this repo and use it as a basis for compiling your own C/Fortran source to Java classes. Keep in mind that we've worked primarily on compiling scientific code that does pure computation, so you won't find implementations of many basic C standard library functions like `fopen()` at this point. ## Next Steps There's alot of interesting things to talk about, so this will be the first post in a series. In subsequent posts, I'll dive into the compiler's internals and look at how we handle anathmas like pointer arithmatic and `malloc()`; I'll explore the performance implications of running C code on the JVM; and finally I'll review the current limitations of the compiler and some potential ways forward.
Markdown
UTF-8
17,374
2.8125
3
[ "Apache-2.0" ]
permissive
1. 数据链路层使用物理层提供的服务在通信信道上发送和接收比特。 2. 功能: - 向网络层提供一个定义良好的服务接口。 - 处理传输错误。(错误控制) - 调节数据流,确保慢速的接收方不会被快速的发送方淹没。(流量控制) 3. 数据包和帧(*frame*)的关系: 数据链路层从网络层获得数据包,然后将这些数据包封装成帧(*frame*)以便传输。每个帧包含一个帧头、一个有效载荷(用于存放数据包〉以及一个帧 尾,如图 3-1 所示。帧的管理构成了数据链路层工作的核心。 ![数据包和帧的关系](data-link-layer/数据包和帧的关系.png) 4. 数据链路层的功能是**为网络层提供服务**。最主要的服务是**将数据从源机器的网络层传输到目标机器的网络层。**链路层对帧通常有严格的长度限制,这是由硬件所决定的;除此之外,还有传播延迟。 一般情况下,数据链路层通常会提供以下 3 种可能的服务: - 无确认的无连接服务:源机器向目标机器发送独立的帧,目标机器并不对这些帧进行确认。 - 适合错误率很低的场合,错误恢复过程可以留给上层来完成。 - 实时通信,如语音传输,因为此时数据迟到比数据受损更糟。 - 有确认的无连接服务 - 发送的每一帧需要单独确认,发送帧可以知道是否正确到达目标,若是超时未到达,将再次发送该帧。 - 尤其适用于不可靠的信道,如无线系统,Wi-Fi就是很好的例子。 - 有确认的有连接服务 - 建立一个连接 - 每一帧都被编号 - 确保每一帧都会被接受 - 每个帧只被接受一次 - 所有帧按正确顺序被接受适用于长距离且不可靠的链路,如卫星通讯或者长途电话 - 最后,连接会被释放 5. 数据链路层必须使用物理层提供给它的服务。检测错误和纠正错误(有必要的话)的工作正是数据链路层该做的。 通常的做法是将比特流拆分成多个离散的帧,为每个帧计算一个称为**校验和(*checksum*)**的短令牌(后面讨论校验和算法),并将该校验和放在帧中一起传输。 <br> 当帧到达目标机器时,要重新计算该帧的校验和。<br> 如果新算出来的校验和与该帧中包含的校验和不同,则数据链路层知道传输过程中产生了错误,它就会采取措施来处理错误〈比 如丢掉坏帧,可能还会发回一个错误报告〉。<br> 拆分比特流的方法: - 字节计数法(*character count*) - 字节填充的标志字节法(*Byte Stuffing or character stuffing*) - 比特填充的标志比特法(*bit stuffing*) - 物理层编码违禁法(*physical layer coding violation*) 6. 字节计数法(*character count*) 利用头部中的一个字段来标识该帧中的字符数,当接收方的数据链路层看到字符计数值时,它就知道后面跟着多少个字节,因此也就知道了该帧在哪里结束。 7. 字节填充的标志字节法(*Byte Stuffing or character stuffing*) 这种方法考虑到了出错之后的重新同步问题,它让每个帧用一些特殊的字节 为开始和结束。这些特殊字节通常都相同,称为**标志字节**(*flag byte*),作为帧的起始和结束分界符。因此,如果接收方丢失了同步,它只需搜索两个标志字节就能找到当前帧的结束和下一帧的开始位置。 当标志字节出现在数据中时,**尤其是当传输二进制数据 (比如照片或歌曲〉时,这种情景往往会严重干扰到帧的分界**。 字节填充( *byte stuffing*):<br> 有一种方法可以解决这个问题,发送方的数据链路层在数据中“偶尔”出现的每个标志字节的前面插入一个特殊的转义字节(*ESC*)。因此,只要看它数据中标志字节的前面有没有转义字节,就可以把作为帧分界符的标志字节与数据中出现的标志字节区分开来。**接收方的数据链路层在将数据传递给网络层之前必须删除转义字节**。 如果转义字节也出现在数据中,那该怎么办?<br> 答案是同样用字节填充技术,即用一个转义字节来填充。*在接收方,第一个转义字节被删除,留下紧跟在它后面的数据字节(或许是另一个转义字节或者标志字节)*。 ![3-4](data-link-layer/3-4.png) 8. 比特填充的标志比特法(*bit stuffing*) - **只能使用 8 比特的字节**。 - 每个帧的开始和结束由一个特殊的比特模式, `01111110` 或十六进制`Ox7E` 标记。 - 这种模式是一个标志字节。每当发送方的数据链路层在数据中遇到连续五个1,便自动在输出的比特流中填入一个比特 0。 - USB (通用串行总线)采用了比特填充技术。 - 当接收方看到 5 个连续入境比特 1,并且后面紧跟一个比特 0,它就自动剔除(即删除)比特 0。 - 比特填充和字节填充一样,对两台计算机上的网络层是完全透明的。 - 如果接收方失去了它的接收轨迹,它所要做的只是扫描输入比特流,找出其中的标志序列。 ![3-5](data-link-layer/3-5.png) 9. 差错控制(*Error Control*) - Error detection - Error correction - Repeated data frame - Lost frame - Timer - 计时器的超时值应该设置得足够长,以便保证在正常情况下该帧能够到达接收方,并且在接收方进行处理后再将确认返回到发送方。 - 一般有必要给发送出去的帧分配序号,这样接收方可以根据帧的序号来有效区分原始帧和重传帧。 10. 流量控制(*Flow Control*) 发送方发送帧的速度超过了接收方能够接受这些帧的速度。 - 基于反馈的流量控制(*feedback-based flow control*): 接收方给发送方返回信息,允许它发送更多的数据。 - 基于速率的流量控制(*Crate-based flow control*): 限制发送方传输数据的速率,而无须利用接收方的反馈信息。 11. 差错检测和纠正 - 纠错码(*error-correcting code*):每一个被发送的数据块中包含足够多的冗余信息。 - 检错码 (*error-detecting code*):包含一些冗余信息,但这些信息只能让接收方推断出是否发生了错误。 |纠错码| |:------:| |海明码| |二进制卷积码| |里德所罗门码| |低密度奇偶校验码| 一帧由m个数据位(即信息)和r个元余位(即校验)组成。 海明距离(*Hamming distance*):两个码字中不相同的位的个数。 `10001001 xor 10110001=>00111000 Hamming distance=3` Hamming distance of a codewords list: 找到两个codewords之间海明距离最小。 ``` 0000000000, 0000011111, 1111100000, and 1111111111 This list has a distance 5 D(a,c) <= D(a,b) + D(b,c),here D(x,y)is the Hamming distance of codeword x and y ``` 纠正d比特需距离为2d+1比特的编码 - 0000000000,0000011111,1111100000,and 1111111111 - 该编码方案的距离是 5,这意味着它可以纠正 2 个错误或者检测双倍的错。 - 0000000000 error => 1100000000 |检错码| |:------:| |奇偶| |校验和| |循环元余校验 (*CCRC*)| || 循环冗余校验码 (*CCRC, Cyclic Redundancy Check*),也称为多项式编(*polynomial code*)。 多项式编码的基本思想是: - 将位串看成是系数为 0或 1 的多项式。 - 一个k位帧看作是一个 k-1 次多项式的系数列表,该多项式共有k项,从 $x^k-1$到$x^0$。这样的多项式认为是 k-1 阶多项式。 - 高次(最左边〉位是$x^k-1$项的系数,接下来的位是$x^k-2$ 的系数,依此类推。 - 例如 110001 有 6 位,因此代表了一个有 6 项的多项式,其系数分别 为 1、 1、 0、 0、 0 和 1: 即$1x^5+1x^4+0x^3+0x^2+0x^1+1x^0$。 - 多项式的算术运算遵守代数域理论规则,以 2 为模来完成。加法没有进位,减法没有借位。加法和减法都等同于异或。例如: ``` 10011011 00110011 - 11001010 +11001101 ------------- ------------ 01010001 11111110 ``` ![CRC 计算示例](data-link-layer/CRC计算示例.png) 12. 停止等待协议 发方每发送一帧就暂停,等待应答(ACK)到来。收方收到数据帧后发ACK帧给发方,发方再发送下一个数据帧。 要解决的问题-[fig lk3-3] - DATA帧出错 - 对策:收方用NAK应答。 - DATA帧丢失 - 对策:使用定时器及重发。 - 收方收到重复的DATA帧 - 对策:帧编号:0,1,0,1...。 ![停止等待协议](data-link-layer/图片%201.png) 13. 基本数据链路层协议 wait_for_event(&event), 3 events: - frame_arrival: Received correct frame. - cksum_err: Received frame with checksum error. - timeout: timeout when sender waits acknowledgement 为什么网络层永远得不到任何帧头的信息,理由非常简单,那就是要保持网络层和数据链路层的完全分离。只要网络层对数据链路协议和帧格式一无所知,那么当数据链路协议和帧格式发生变时,网络层软件可以不作任何改变。每当一块新 NIC 安装在计算机上时这种情况就会发生。 * 无错信道上的单工停-等式协议:<br> 发送方网络层无限制的数据传输,信道永不损坏或丢失。<br> 丢弃限制条件:接收器的网络层可以接收无限的数据。 * 有错信道上的单工停-等式协议 如果在一个协议中,发送方在前移到下一个数据之前必须等待一个肯定确认,这样的协议称为自动重复请求(*ARQ , Automatic Repeat reQuest*)或带有重传的肯定确认( *PAR, Positive Acknowledgement with Retransmission*)。 当发送方和接收方的数据链路层处于等待状态时,两者都用一个变量记录下了有关的值。发送方在 `next frame to send` 中记录了下一个要发送的帧的序号:接收方则在`frame_expected` 中记录了下一个期望接收的序号。每个协议在进入无限循环之前都有一个简短的初始化阶段。 发送方在发出一帧后启动计时器。如果计时器己经在运行,则将它重置,以便等待另一个完整的超时时间间隔。 当一个有效帧到达接收方时,接收方首先检查它的序号,确定是否为重复数据包。如果不是,则接受该数据包并将它传递给网络层,然后生成二个确认帧。 ![](data-link-layer/1.png) ![](data-link-layer/2.png) ![](data-link-layer/3.png) ![](data-link-layer/4.png) 14. 滑动窗口协议 * 双向传输 * 暂时延缓确认以便将确认信息搭载在下一个出境数据帧上的技术就称为捎带确认 (*piggybacking*)。[使用帧头的ack字段] * 更好地利用了信道的可用带宽。 双向协议,在这 3 个协议中,任何一个出境帧都包含一个序号, 范围从 0 到某个最大值。序号的最大值通常是 $2^n一1$,这样序号正好可以填入到一个 n 位的 字段中。<br> 停-等式滑动窗口协议使用 $n=1$,限制了序号只能是 0 和 1,但是更加复杂的协议版本可以使用任意的n。 * 1 位滑动窗口协议 所有滑动窗口协议的本质是**在任何时刻发送方总是维持着一组序号**,分别对应于允许它发送的帧,我们称这些帧落在发送窗口(*sending window*)。 ![大小为 1 的滑动窗口,序号 3 位](data-link-layer/3-15.png) 在一般情况下,两个数据链路层中的某一个首先开始,发送第一帧。 当该帧(或者任何其他帧)到达目的地,接收方的数据链路层检查该帧,看它是否为重复帧,如同协议 3 一样。如果这帧正是接收方所期望的,则**将它传递给网络层**,井且接收方的窗口向前滑动。 ![协议 4 的两种场景](data-link-layer/3-17.png) * 回退 N 协议 这个方案的基本思想是允许发送方在阻塞之前发送多达 w 个帧,而不是一个帧。通过选择足够大的 w 值,发送方就可以连续发送帧,因为在发送窗口被填满之前前面帧的确认就返回了,因而防止了发送方进入阻塞。 这种容量由比特/秒的带宽乘以单向传送时间所决定,或数据链路层有责任以链路的**带宽-延迟乘积** (*bandwidth-delay product*)序列把数据包传递给网络层。 我们可以将这个数量拆分成一帧的比特数,从而用帧的数量来表示。我们将这个数值称为**BD**。因此, w应设置为`2BD+1`。 具有 50 kbps 的带宽和 250 毫秒的单向传输时间,带宽-延迟乘积为2.5kb 或 12.5个长度为 1000位的帧。因此,2BD+1 是 26 帧。 我们可以将链路利用率表示成发送方未被阻塞的时间比例: $链路利用率<=w/(1+2BD)$ 位于某个数据流中间的一个帧被损坏或丢失,会发生什么事情?<br> **在发送方发现问题之前大量的后续帧已经发出,并且即将到达接收方**。<br> 当损坏的那个帧到达接收方时,显然它应该被丢弃,但接收方该如何处理 所有那些后续到达的正确帧呢?<br>请记住,接收方的数据链路层有责任按正确的顺序把数据包传递给网络层。 ![管道化以及差错恢复](data-link-layer/3-18.png) > 0 号帧和 1号帧被正确接收,并得到确认; 2号帧丢失了。当3号帧到达接收方时,那里的数据链路层注意到自己错过了一帧,所以它针对错失的 2 号帧返 回一个 NAK,但是将第 3 帧缓存起来。当 4 号和 5 号帧到达之后,它们也被数据链路层缓存起来,而没有被传递给网络层。 2号帧的 NAK抵达发送方后,发送方立即重传2号帧。 当该帧到达接收方时,数据链路层现在有了 2 号、 3 号、 4 号和 5 号帧,于是就将它们按照正确的顺序传递给网络层,也可以确认所有这些帧(从 2 号帧到 5 号帧),如图中所示。如果 NAK 被丢失,则发送方的 2 号帧计时器最终超时,发送方就会重新发送 2 号帧(仅仅这一帧〉,但是,这可能已经过了相当长一段时间。 (1) 回退n(*go-back-n*) 接收方只需简单丢弃所有到达的后续帧,而且针对这些丢弃的帧不返回确认。这种策略对应于接收窗口大小为 1 的情形。 由于发送方可能必须在将来的某个时间重新发送所有未确认的帧,因此它必须缓冲所有已发送的帧,直到确认到达为止。 - 未确认帧的最大数目必须限制为不能超过 `MAX_SEQ`。 - 发送窗口不大于`MAX_SEQ`。 - 累计确认(*cumulative acknowledgement*) - 由于发 送方可能在将来的某个时刻要重传所有未被确认的帧,所以,它必须把己经发送出去的帧一直保留,直到它能肯定接收方已经接受了这些帧。当 n 号帧的确认到达, n-1 号帧、 n-2 号帧等都会自动被确认。 - 只需使用一个硬件时钟,它周期性地引发中断。所有未发生的超时事件构成了一个链表,链表中的每个节点包含了离超时还有多少小时钟滴答、超时对应 的那个帧,以及一个指向下一个节点的指针。 (2) 选择重传(*selective repeat*)。 - 允许接收方接受并缓存坏帧或者丢失帧后面的所有帧。 - 发送方和接收方各自维持一个窗口,该窗口分别包含可发送或己发送但未被确认的和可接受的序号。 - 发送方的窗口大小从 0 开始,以后可以增大到某一个预设的最大值。 - 接收方的窗口总是固定不变,其大小等于预先设定的最大值。 - 接收方为其窗口内的每个序号保留一个缓冲区。与每个缓冲区相关联的还有一个标志位(*arrived*), 用来指明该缓冲区是满的还是空的。 - 每当到达一帧,接收方通过 between 函数检查它的序号,看是否落在窗口内。 - 如果确实落在窗口内,并且以前没有接收过该帧,则接受该帧,并且保存在缓冲区。 - 不管这帧是否包含了网络层所期望的下一个数据包,这个过程肯定要执行。当然,该帧只能被保存在数据链路层中,直到所有序号比它小的那些帧都己经按序递交给网络层之后,它才能被传递给网络层。 - 对于不按序到达的帧,不丢弃,而是保存起来,等所缺的帧到达后,把保存起来的那些顺序正确的多个帧一并上交。 - 接收窗口的大小要等于发送窗口的大小; - 对于3 bit序号值,序号范围为 0-7,即MAX_SEQ=7,发送窗口的大小为`(MAX_SEQ+1)/2=4`,接受窗口的大小=4。 - 发送窗口的大小不能大于`(MAX_SEQ+1)/2`,这里是4(设MAX_SEQ=7),否则应答(ack)丢失的情况,二者的窗口会有重叠部分。 - 如果发送窗口的大小是4或更小,则问题解决: - A的发送窗口=[0,1,2,3], B的接收窗口=[0,1,2,3] - A向B发送 0、1、2、3#帧,两种不同的情况发生了: - 情况1:B收到全部4个帧,应答也全部被A收到; - A新的发送窗口=[4,5,6,7] - B新的接收窗口=[4,5,6,7] - 新发4,5,6,7#帧; - 情况2:4个帧全部收到,但应答全部丢失 - A的发送窗口=[0,1,2,3] - B的接收窗口=[4,5,6,7] - A重发0#帧; - 没问题:新来的0#帧不在接收窗口内,是重发的,应丢弃。 ![](data-link-layer/图片.png)
C++
UTF-8
13,620
2.796875
3
[]
no_license
#include "AgenciaViajes.h" //#include <iostream> #include <stdio.h> //#include <string> #include <stdlib.h> #include <string.h> #include <fstream> #include <sstream> //#include <windows.h> #include <vector> using std::vector; using namespace std; AgenciaViajes::AgenciaViajes() { primerViaje = NULL; } AgenciaViajes::~AgenciaViajes() { //dtor } //LECTURAS DE ARCHIVOS void AgenciaViajes::lecturaArchivosViaje(string archivo){ fstream ficheroEntrada; string linea; //string archivo; int lenLinea; string atributo; vector<string> elementos(0); char separador = ';'; ficheroEntrada.open(archivo.c_str(),ios::in); //int i2 = 0; if (ficheroEntrada.is_open()){ while (!ficheroEntrada.eof()){ getline(ficheroEntrada,linea); lenLinea = linea.size(); for (int i = 0; i < lenLinea; i++){ if(linea[i] != separador){ atributo = atributo + linea[i]; }else{ elementos.push_back(atributo); atributo = ""; } } elementos.push_back(atributo); //llamada a funcion para validar que los IDE sean unicos //validarElementos(elementos); cout<<"-----------------------------------Viajes-----------------------------------"<<endl; cout<<"----------------------------------------------------------------------------"<<endl; //int idViaje = atoi(elementos[0].c_str());cout<<"ID Viaje: "<<idViaje<<endl; string idViaje = elementos[0];cout<<"ID Viaje: "<<idViaje<<endl; string origenViaje = elementos[1];cout<<"Origen Viaje: "<<origenViaje<<endl; string destinoViaje = elementos[2];cout<<"Destino del viaje:"<<destinoViaje<<endl; string fechaSalida = elementos[3];cout<<"Fecha de salida: "<<fechaSalida<<endl; string fechaLlegada = elementos[4];cout<<"Fecha de llegada: "<<fechaLlegada<<endl; string precioViaje = elementos[5];cout<<"Precio del viaje: "<<precioViaje<<endl; string plazasViaje = elementos[6];cout<<"Numero de plazas: "<<plazasViaje<<endl; //cout<<"----------------------------------------------------------------------------"<<endl; crearViaje(idViaje, origenViaje, destinoViaje,fechaSalida, fechaLlegada, precioViaje, plazasViaje); elementos.clear(); atributo = ""; } ficheroEntrada.close(); }else{ cout << "Fichero inexistente o faltan permisos para abrirlo" << endl; } } void AgenciaViajes::lecturaArchivosHotel(string archivo){ fstream ficheroEntrada; string linea; //string archivo; int lenLinea; string atributo; vector<string> elementos(0); char separador = ';'; ficheroEntrada.open(archivo.c_str(),ios::in); //int i2 = 0; if (ficheroEntrada.is_open()){ while (!ficheroEntrada.eof()){ getline(ficheroEntrada,linea); lenLinea = linea.size(); for (int i = 0; i < lenLinea; i++){ if(linea[i] != separador){ atributo = atributo + linea[i]; }else{ elementos.push_back(atributo); atributo = ""; } } elementos.push_back(atributo); cout<<"-----------------------------------Hoteles-----------------------------------"<<endl; cout<<"----------------------------------------------------------------------------"<<endl; //int idViaje = atoi(elementos[0].c_str());cout<<"ID Viaje: "<<idViaje<<endl; string idViaje = elementos[0];cout<<"ID Viaje: "<<idViaje<<endl; string idHotel = elementos[1];cout<<"ID Hotel: "<<idHotel<<endl; string nombre = elementos[2];cout<<"Nombre: "<<nombre<<endl; string categoria = elementos[3];cout<<"Categoria: "<<categoria<<endl; string ciudad = elementos[4];cout<<"Ciudad: "<<ciudad<<endl; string precioHabIndividual = elementos[5];cout<<"Precio habitacion dobre: "<<precioHabIndividual<<endl; string precioHabDoble = elementos[6];cout<<"Precio habitacionindividual: "<<precioHabDoble<<endl; //crearHotel(idViaje, idHotel, nombre,categoria, ciudad, precioHabIndividual, precioHabDoble); elementos.clear(); atributo = ""; } ficheroEntrada.close(); }else{ cout << "Fichero inexistente o faltan permisos para abrirlo" << endl; } } void AgenciaViajes::lecturaArchivosTransporte(string archivo){ fstream ficheroEntrada; string linea; //string archivo; int lenLinea; string atributo; vector<string> elementos(0); char separador = ';'; ficheroEntrada.open(archivo.c_str(),ios::in); //int i2 = 0; if (ficheroEntrada.is_open()){ while (!ficheroEntrada.eof()){ getline(ficheroEntrada,linea); lenLinea = linea.size(); for (int i = 0; i < lenLinea; i++){ if(linea[i] != separador){ atributo = atributo + linea[i]; }else{ elementos.push_back(atributo); atributo = ""; } } elementos.push_back(atributo); cout<<"-----------------------------------Transporte-----------------------------------"<<endl; cout<<"----------------------------------------------------------------------------"<<endl; //int idViaje = atoi(elementos[0].c_str());cout<<"ID Viaje: "<<idViaje<<endl; string idViaje = elementos[0];cout<<"ID Viaje: "<<idViaje<<endl; string idHotel = elementos[1];cout<<"ID Hotel: "<<idHotel<<endl; string idTransporte = elementos[2];cout<<"ID Trasnporte: "<<idTransporte<<endl; string tipoTranporte = elementos[3];cout<<"Tipo: 1Aereo-2Maritimo-3Terrestre: "<<tipoTranporte<<endl; string origen = elementos[4];cout<<"Origen: "<<origen<<endl; string destino = elementos[5];cout<<"Destino: "<<destino<<endl; string fechaSalida = elementos[6];cout<<"Fecha Salida: : "<<fechaSalida<<endl; string horaSalida = elementos[7];cout<<"Hora Salida: "<<horaSalida<<endl; string fechaLlegada= elementos[8];cout<<"Fecha Legada: "<<fechaLlegada<<endl; string horaLegada = elementos[9];cout<<"Hora Llegada: "<<horaLegada<<endl; string compania = elementos[10];cout<<"Compania: "<<compania<<endl; string numPlazas = elementos[11];cout<<"Numero de Plazas: "<<numPlazas<<endl; string precio = elementos[12];cout<<"Precio: "<<precio<<endl; //crearTransporte(idViaje, idHotel, nombre,categoria, ciudad, precioHabIndividual, precioHabDoble); elementos.clear(); atributo = ""; } ficheroEntrada.close(); }else{ cout << "Fichero inexistente o faltan permisos para abrirlo" << endl; } } void AgenciaViajes::lecturaArchivosOferta(string archivo){ fstream ficheroEntrada; string linea; //string archivo; int lenLinea; string atributo; vector<string> elementos(0); char separador = ';'; ficheroEntrada.open(archivo.c_str(),ios::in); //int i2 = 0; if (ficheroEntrada.is_open()){ while (!ficheroEntrada.eof()){ getline(ficheroEntrada,linea); lenLinea = linea.size(); for (int i = 0; i < lenLinea; i++){ if(linea[i] != separador){ atributo = atributo + linea[i]; }else{ elementos.push_back(atributo); atributo = ""; } } elementos.push_back(atributo); //llamada a funcion para validar que los IDE sean unicos //validarElementos(elementos); cout<<"-----------------------------------Oferta-----------------------------------"<<endl; cout<<"----------------------------------------------------------------------------"<<endl; string idViaje = elementos[0];cout<<"ID Viaje: "<<idViaje<<endl; string idHotel = elementos[1];cout<<"ID Hotel: "<<idHotel<<endl; string precioHabIndiv = elementos[2];cout<<"Precio Habitacion individual:"<<precioHabIndiv<<endl; string precioHabDoble = elementos[3];cout<<"Precio Habitacion doble: "<<precioHabDoble<<endl; cout<<"----------------------------------------------------------------------------"<<endl; cout<<endl; cout<<endl; cout<<endl; elementos.clear(); atributo = ""; } ficheroEntrada.close(); }else{ cout << "Fichero inexistente o faltan permisos para abrirlo" << endl; } } //CREACION DE NODOS void AgenciaViajes::crearViaje(string idV, string origenViaje, string destinoViaje, string fechaSalidaViaje, string fechaLlegadaViaje, string precioViaje, string numPlazasViaje){ pnodoViaje nuevoViaje = new NodoViaje(idV ,origenViaje , destinoViaje ,fechaSalidaViaje,fechaLlegadaViaje ,precioViaje ,numPlazasViaje); if(listaViajesVacia()){ //solo si es vacia yo creo este nodo primerViaje = nuevoViaje; primerViaje->sigViaje = primerViaje; primerViaje->antViaje = primerViaje; }else{ pnodoViaje aux = primerViaje; while(aux->sigViaje != primerViaje){ aux = aux->sigViaje; } aux -> sigViaje = nuevoViaje; nuevoViaje -> antViaje = aux; nuevoViaje -> sigViaje = primerViaje; primerViaje -> antViaje = nuevoViaje; aux->listaHotel =NULL;//asegurarse que el nodo todavia no tiene nada } } /*void AgenciaViajes::crearHotel(string idV, string idH, string nombreHotel, string categoriaHotel, string ciudadHotel, string precioHabIndividualHotel, string precioHabDobleHotel){ pnodoHotel nuevoHotel = new NodoHotel(idV,idH , nombreHotel ,categoriaHotel,ciudadHotel ,precioHabIndividualHotel ,precioHabDobleHotel); pnodoViaje vij = ViajeEncontrado(idV); //uso a nuevo como primero if(listaHotelVacia(idV)){ vij->listaHotel = nuevoHotel; nuevoHotel->devolverViaje = vij; nuevoHotel->sigHotel = NULL; nuevoHotel->antHotel = NULL; }else{ pnodoHotel primerH = vij->listaHotel; pnodoHotel aux = primerH; while(aux->sigHotel != NULL){ aux = aux->sigHotel; } aux->sigHotel = nuevoHotel; aux->sigHotel->antHotel= aux; aux->sigHotel->sigHotel = NULL; aux->sigHotel->devolverViaje=NULL; nuevoHotel=NULL; } } */ //METODOS DE VALIDACIONES DE LISTAS bool AgenciaViajes::listaViajesVacia(){ return primerViaje == NULL; } /*bool AgenciaViajes::listaHotelVacia(int idV){ pnodoViaje vij = ViajeEncontrado(idV); if(vij->listaHotel == NULL){ return true; } return false; } */ //METODOS PARA MOSTRAR void AgenciaViajes :: MostrarListaViajes(){ cout<<"Lista Viajes: "<<endl; cout<<endl; pnodoViaje aux = primerViaje; while(aux->sigViaje != primerViaje){ cout<<aux->idViaje<<";"<<aux->origen<<";"<<aux->destino<<";"<<aux->fechaSalida<<";"<<aux->fechaLegada<<";"<<aux->precio<<";"<<aux->numPlazas<<" -> "; aux = aux->sigViaje; } cout<<aux->idViaje<<";"<<aux->origen<<";"<<aux->destino<<";"<<aux->fechaSalida<<";"<<aux->fechaLegada<<";"<<aux->precio<<";"<<aux->numPlazas<<" -> "; } /*void AgenciaViajes :: MostrarListaHotel(){ cout<<"Lista Hotel: "<<endl; cout<<endl; pnodoHotel aux = listaHotel; //aux = pnodoViaje->listaHotel; while(aux->sigHotel != NULL){ cout<<aux->idHotel<<";"<<aux->idHotel<<";"<<aux->nombre<<";"<<aux->categoria<<";"<<aux->ciudad<<";"<<aux->precioHabIndividual<<";"<<aux->precioHabDoble<<" -> "; aux = aux->sigHotel; } cout<<aux->idViaje<<";"<<aux->idHotel<<";"<<aux->nombre<<";"<<aux->categoria<<";"<<aux->ciudad<<";"<<aux->precioHabIndividual<<";"<<aux->precioHabDoble<<" -> "; } */ /*bool AgenciaViajes::ViajeExistente(int idV) { pnodoViaje aux = primerViaje; while ( aux->sigViaje != primerViaje){ if (aux->idViaje == idV) return true; aux = aux->sigViaje; } if (aux->idViaje == idV) return true; return false; } pnodoViaje AgenciaViajes::ViajeEncontrado(int idV) { pnodoViaje aux = primerViaje; while ( aux -> sigViaje != primerViaje){ if (aux->idViaje == idV) return aux; aux = aux -> sigViaje; } if (aux->idViaje == idV) return aux; return NULL; } */ void AgenciaViajes::Menu(){ cout<<"________________________________________________"<<endl; cout<<"________________________________________________"<<endl; cout<<"AGENCIA DE VIAJES"<<endl; cout<<"BIENVENIDO"<<endl; cout<<"________________________________________________"<<endl; cout<<"Digite la opcion a la que desea ingresar"<<endl; cout<<"________________________________________________"<<endl; cout<<"1.Consultar precio de un producto"<<endl; cout<<"2.Consultar hoteles, viajes y transportes"<<endl; cout<<"3.Consultar el viaje de un cliente"<<endl; cout<<"3.1.Consultar el transporte de un cliente"<<endl; cout<<"3.2.Consultar la resrva de un cliente"<<endl; cout<<"________________________________________________"<<endl; cout<<"________________________________________________"<<endl; }
Markdown
UTF-8
6,008
2.890625
3
[]
no_license
--- layout: post title: "Business for 6 Year Olds Part 2" page_img: page_img_desc: "" no_ad: 1 tags: bf6yo bf6yo_title: "Part 2" bf6yo_description: "what a business has" --- I've been ramping up A.'s knowledge of business. So first we discussed <a href="/2016/12/03/business-for-6-year-olds-part-1.html">what a business is</a> and we worked together to find some examples. Later that night we discussed what a business has: <dt>Dan</dt> <dd>So A., remember this morning we talked about what a business is?</dd> <dt>A.</dt> <dd>Yep!</dd> <dt>Dan</dt> <dd>Do you know we know someone who runs a gymnastics business.</dd> <dt>A.</dt> <dd>Wow, who?</dd> <dt>Dan</dt> <dd>Aunt Paula and uncle Bob. Do you know what they do?</dd> <dt>A.</dt> <dd>Oh yeah, they're gymnastics teachers!</dd> <dt>Dan</dt> <dd>That's right, and they have their own gym. And do you know who else has their own business?</dd> <dt>A.</dt> <dd>Who?</dd> <dt>Dan</dt> <dd>Uncle Ladd and aunt Rose.</dd> <dt>A.</dt> <dd>What do they do?</dd> <dt>Dan</dt> <dd>They take old furniture and replace the cloth on it and some of the pieces inside so it's new and nice.</dd> <dt>A.</dt> <dd><i>(Excited)</i> I want to have a business like that!</dd> <dt>Dan</dt> <dd>Well, unfortunately it's a difficult business to be in, because people aren't doing that as much as they used to. They aren't having their furniture fixed very often.</dd> <i>A. looks dejected here.</i> <dt>Dan</dt> <dd>But it could be a good hobby. You'd probably have a lot of fun.</dd> <dt>A.</dt> <dd>Yes!</dd> <dt>Dan</dt> <dd>And you know who else has a business?</dd> <dt>A.</dt> <dd>Who?</dd> <dt>Dan</dt> <dd>Papi Percy and Mami Lucy! <i>(Her grandparents.)</i> Do you know what they do?</dd> <dt>A.</dt> <dd>They build buildings! Mami has that business. <i>(My wife.)</i></dd> <dt>Dan</dt> <dd>That's right. Mami was trained to do that. She doesn't do it right now.</dd> <i>I let A. think about all these things for a few minutes before I continue. It's time to explain what a business has. Which will help differentiate it from other concepts like "a job".</i> <dt>Dan</dt> <dd>So A., what does a business have?</dd> <dt>A.</dt> <dd><i>(Thinks real hard.)</i></dd> <dt>Dan</dt> <dd>Like, what does a gardener have?</dd> <dt>A.</dt> <dd>Oh! Something to dig with!</dd> <dt>Dan</dt> <dd>Yes! A shovel.</dd> <dt>A.</dt> <dd>And flowers.</dd> <dt>Dan</dt> <dd>Yes, and what does a house-cleaning person need?</dd> <dt>A.</dt> <dd>Um, something to clean with.</dd> <dt>Dan</dt> <dd>Yes. Sometimes they go and just use the cleaning stuff that is already at the house, but sometimes they bring their own cleaning stuff.</dd> <dd>What does a garbage company need?</dd> <dt>A.</dt> <dd>Um... Oh! A garbage truck!</dd> <dt>Dan</dt> <dd>Yep. That's almost all they need. They also need a place to keep their garbage truck. Maybe they own a place or maybe they pay someone to use their place to keep their garbage truck in.</dd> <dd>So what does an architect need? What do Papi Percy and Mami Lucy need?</dd> <dt>A.</dt> <dd>Um... what's that stuff that holds bricks together?</dd> <dt>Dan</dt> <dd>Cement, yes they need cement.</dd> <i>(About this time, my wife Pati came in the kitchen.)</i> <dt>A.</dt> <dd>And bricks! If the house is made of bricks.</dd> <dt>Pati</dt> <dd>Yep. And they also need a computer.</dd> <dt>Dan</dt> <dd>Yeah, to draw what they're going to build. They might draw the idea first on paper, but then they use a computer to make sure they know exactly how big everything has to be.</dd> <i>I let her think about that stuff for just a moment.</i> <dt>Dan</dt> <dd>There's one thing that all businesses have to have.</dd> <dt>A.</dt> <dd>Money?</dd> <dt>Dan</dt> <dd>Actually yes, they all need that. And where do they get it?</dd> <dt>A.</dt> <dd><i>(Pause.)</i></dd> <dt>Dan</dt> <dd>Where does a gardener get money?</dd> <dt>A.</dt> <dd>From the people who live in the garden.</dd> <dt>Dan</dt> <dd>From the people who own the garden.</dd> <dt>A.</dt> <dd>That's what I said!</dd> <dt>Dan</dt> <dd>Ok, you're right. Yes, the people who own the garden pay the gardener to mow their lawn and plant their flowers. They're called the customers.</dd> <dd>Who are the customers of a house-cleaning person?</dd> <dt>A.</dt> <dd>The people who live in the house.</dd> <dt>Dan</dt> <dd>That's right. Who are the customers of a gymnastics business? It's not the kids. It's the parents, right?</dd> <dt>A.</dt> <dd><i>(Nods.)</i></dd> <dt>Dan</dt> <dd>If a business doesn't have customers it is not a business.</dd> <dt>A.</dt> <dd>Who is the customer of the firetruck?</dd> <dt>Dan</dt> <dd>Firefighters are a different story. If they had customers, then only people who could afford firefighters would have their houses saved from fires. The same is true for policemen...</dd> Then I started talking about government and didn't come back to the topic of business. Since I mentioned all these people, here you go: If you're interested in furniture upholstery in North Florida, take a look at <a href="http://www.northfloridachair.com">Ladd Upholstery Designs</a>. If you're interested in attending gymnastics classes in Greenville, South Carolina, look at <a href="http://www.penultimategym.com">PENultimate Gymnastics</a>. Or if you're interested in leotards, <a href="http://www.etsy.com/shop/PENultimateLeotards">PENultimate Leotards</a> is the place to go. If you're interested in architecture and construction in Santa Cruz, Bolivia, look up Percy Alvarez or contact me for more info. <blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">What does a business have? Discussion with my six year old. <a href="https://t.co/ONZ7l54CMW">https://t.co/ONZ7l54CMW</a></p>&mdash; Dan Kuck-Alvarez (@dankuck) <a href="https://twitter.com/dankuck/status/806611988520599553">December 7, 2016</a></blockquote> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> {% include series_bf6yo.html %}
JavaScript
UTF-8
178
2.78125
3
[]
no_license
// Configuração var lastName = "Lovelace"; // Altere apenas o código abaixo desta linha var secondToLastLetterOfLastName = lastName[lastName.length - 2]; // Altere esta linha
Markdown
UTF-8
15,706
2.90625
3
[ "MIT" ]
permissive
# 3. Criando um ponto de acesso Wi-fi pelo NODEMCU e armazenando arquivos na memória flash do ESP8266 A partir do módulo 3 os projetos desenvolvidos nesse repositório passaram a depender do acesso a internet, isto é, as aplicações dependem de uma rede Wi-Fi para que o ESP 8266 possa se conectar. Contudo, nem sempre teremos uma rede Wi-fi estável ou disponível e ainda assim, precisaremos desenvolver aplicações de Internet das Coisas (IoT) que necessitam estar interconectados via uma rede. Felizmente é possível criar um ponto de acesso configurável e customizável através do ESP 8266. Além disso, objetivando uma maior facilidade na construção e gerenciamento de projetos, sobretudo projetos grandes, detalhados e com várias partes distintas, faz-se necessário reduzir a quantidade de códigos. Imagine, por exemplo, que você precisa criar um Web-server com várias páginas distintas e precisa conectá-lo ao seu projeto físico, será que não ficaria impráticável ter que codificar todas as páginas e colocar junto ao seu código principal? Portanto, através do que será ensinado nessa seção, aprenderemos uma maneira de gerenciar nosso projeto, deixando informações secundárias em uma pasta específica que não irá interferir no projeto principal. Para esta seção, vamos utilizar o webserver desenvolvido na anterioreriormente, o [Webserver com página dinâmica, usando AJAX](https://github.com/PETEletricaUFBA/automacao-iot-nodemcu/tree/master/M%C3%B3dulo%203/Webserver/2.%20Webserver%20com%20p%C3%A1gina%20din%C3%A2mica%2C%20usando%20AJAX). > Nessa seção você irá aprender a criar um ponto de acesso Wi-fi com o ESP8266 e utilizar o sistema de arquivos do ESP8266, o SPIFFS (SPI Flash File System) para salvar códigos, imagens, arquivos de texto dentro do seu microcontrolador, retirando assim,os códigos secundários, páginas, imagens do seu webserver do seu código principal em C, possibilitando, portanto, um gerenciamento eficiente do seu projeto e a idependência de uma rede com acesso a internet. ___ O ESP8266 apresenta um sistema de gerenciamento de arquivos responsável por armazenar arquivos pequenos chamado de SPIFFS (SPI Flash Filing System). Esse sistema, por sua vez, foi desenvolvido para que pudesse servir como uma memória para dispositivos que apresentam um baixo uso de memória RAM, como é o caso do módulo NODEMCU 8266. A partir do SPIFFS permite-se o acesso à memória flash do ESP8266 possibilitando instalar e armazenar os diferentes arquivos que estão sendo usados pelo seu programa, como pode ser visualizado na figura abaixo: ![](https://codimd.s3.shivering-isles.com/demo/uploads/upload_c4e076123db7ba554769e0b0b99ac9ea.png) No entanto, o sistema SPIFFS apresenta algumas características e limitações como: - Os arquivos são armazenados em um mesmo diretório e, portanto, não é possível armazenar pastas. - O nome dos arquivos não pode ser maior que 32 caracteres. - Um nome de arquivo pode começar com o caracter `"/"`. Exemplo: `/exemplo/teste.html`. ## Conteúdo - [Materiais Necessários](#materiais-necessários) - [Montagem do Circuito](#montagem-do-circuito) - [Preparando a IDE com as ferramentas de programação](#preparando-a-ide-com-as-ferramentas-de-programação) - [O Código do Circuito](#o-c&oacute;digo-do-circuito) ## Materiais Necessários 1. NodeMCU 2. 4 LEDs 3. 4 Resistores de 220Ω a 1KΩ 4. Protoboard 5. Jumpers ## Preparando a IDE com as ferramentas de programação ### Instalando o gravador do sistema de arquivos na IDE do Arduino 1. Navegue até este [ link de download](https://github.com/esp8266/arduino-esp8266fs-plugin/releases) e baixe a última versão do arquivo .zip. Exemplo: `ESP8266FS-0.5.0.zip` ![](https://codimd.s3.shivering-isles.com/demo/uploads/upload_ec967aed16e2ae8e97c7fad3472b2bba.png) 2. O segundo passo é ir até o local no seu computador onde a IDE do Arduino foi instalada. Depois disso, encontre a pasta tools. ![](https://codimd.s3.shivering-isles.com/demo/uploads/upload_c13d1aa7e7f82c4e1d727d220cda280e.jpg) 3. Extraia o arquivo dentro da pasta tools que foi mostrada no item anterior: ![](https://codimd.s3.shivering-isles.com/demo/uploads/upload_ee74bf8ede48495347e89dfeba9a9853.jpg) Após extrair, a sua estrutura de arquivos ficará da seguinte forma: ``` tools └── ESP8266FS └── tool └── esp8266fs.jar ``` 4. Reinicie a IDE do Arduino. 5. Para verificar se o gravador do sistema de arquivos está instalado corretamente na IDE do Arduino. Vá para Ferramentas e verifique se o gravador foi instalado com sucesso, como pode ser visualizado na figura a seguir: ![](https://codimd.s3.shivering-isles.com/demo/uploads/upload_e1dd4fc24fd26666300d2ca2bb2921e6.jpg) ### Instalando as bibliotecas para criação do ## Montagem do Circuito O circuito deve ser montado como mostra a figura abaixo, representado na protoboard. <p align="center"> <img src="assets/circuit.jpg" alt="Protoboard"/> </p> Para esta aplicação utilizamos quatro LEDs de cores diferentes. Como visualizado na figura, cada LED deve ser conectado a um pino digital e ao GND. O detalhe importante é a utilização e necessidade de um resistor para controle de corrente. ## O código do Circuito Use o código que está em [code](code/code.ino) A primeira coisa você deve fazer é mudar este trecho de código, inserindo o nome da sua rede WiFi e a sua senha (fique tranquilo(a), essa informação não será divulgada na internet). Realizar essa ação só permite que o seu ESP se conecte na sua rede Wi-fi, assim como o seu celular e outros dispositivos móveis, por exemplo. ```c++ const char* ssid = "NOME DA SUA REDE"; const char* password = "SENHA DA SUA REDE"; ``` E por último, você deve editar essas linhas. Os parâmetros da segunda e da terceira linha se referem ao gateway padrão e máscara de sub-rede que podem ser encontradas seguindo este [tutorial](https://www.sony.com.br/electronics/support/laptop-pc-sve-series/sve15111ebs/articles/00022321). Os três primeiros parâmetros do _ip_ você deve mantê-los iguais aos do _gateway_, já no último parâmetro você coloca um número entre 100 e 255. Escolhemos, de forma pessoal, o número 234 ```c++ IPAddress ip(192,168,100,234); IPAddress gateway(192,168,100,0); IPAddress subnet(255,255,255,0); ``` Um outro trecho de código que vale a pena uma explicação mais detalhada é a seguinte: ```c++ void updateLight() { String ledStatusParam = server.arg("lightStatus"); if (ledStatusParam == "ON") lightStatus = HIGH; else lightStatus = LOW; digitalWrite(lightPin, lightStatus); server.send(200, "text/plain", "Sucesso!"); } ``` `String ledStatusParam=server.arg("lightStatus") `permite consultar o valor da variável lightStatus através do parâmetro em javascript que foi adicionado anteriormente. (É uma conexão entre o projeto físico e a parte virtual do projeto) Posteriormente, através da estrutura condicional, e após consultar o estado da variável, garantimos, a mudança do estado de saída para HIGH ou LOW ```c++ void updateAir() { String airStatusParam = server.arg("airStatus"); String airTempParam = server.arg("airTemp"); if (airStatusParam == "ON") analogWrite(airPin,map(airTempParam.toInt(), 15, 28, 0, 1023)); else digitalWrite(airPin, LOW); server.send(200, "text/plain", "Sucesso!"); } ``` Diferentemente das outras três funções que foram implementadas para a lâmpada, porta e tomadas, o ar condicionado é uma grandeza analógica quantizada, assume uma faixa de valores previamente definidas, isto é, o ar condicionado da sua residência consegue variar entre 16°C e 28°C, enquanto a tomada e as lâmpadas estão ligadas ou desligadas, apenas. Semelhante ao que foi feito para as outras saídas, armazena-se o estado da variável `airStatus` e `airTem`. Nesse sentido, caso um usuário deseje alterar o valor atual da temperatura, a requisição efetuada pelo usuário enviará ao servidor a informação `"ON"` + a alteração do valor de temperatura. `analogWrite(airPin,map(airTempParam.toInt(), 15, 28, 0, 1023))` Semelhante ao que você aprendeu em escrita analógica, há a conversão direta entre a informação analógica 15°C~28°C e a informação processada pelo ADC de 10 bits que varia de 0 a 1023. Por fim, caso o usuário queira desligar o aparelho, a informação enviada ao servidor Web é `LOW` e com isso altera-se o seu estado atual para desligado. Uma vez que se houve a compreensão da parte inicial do nosso código, faz-se necessário entender os processos que são realizados com Javascript. Falaremos somente um pouco sobre as funções, caso você queira aprender mais sobre JavaScript, [clique aqui](https://www.w3schools.com/js/default.asp). A seguir explicaremos um pouco as funções do `JavaScript`. Note que o código pode estar um pouco diferente em algums momentos como no lugar de `"` tem um `\"`, isso se deve ao fato de o código Javascript está dentro de uma string em C, por isso, teve que ser feito esse artifício. O primeiro processo que vale a pena destacar é o realizado pela `function init()` que está abaixo: ```c++ function init() { var xhttp1 = new XMLHttpRequest(); xhttp1.open("GET", "toggleLight?lightStatus="+lightStatus, true); xhttp1.send(); var xhttp2 = new XMLHttpRequest(); xhttp2.open("GET", "toggleOutlet?outletStatus="+outletStatus, true); xhttp2.send(); var xhttp3 = new XMLHttpRequest(); xhttp3.open("GET", "toggleDoor?doorStatus="+doorStatus, true); xhttp3.send(); var xhttp4 = new XMLHttpRequest(); xhttp4.open("GET", "toggleAir?airStatus="+airStatus+"&airTemp="+slideAir.value, true); xhttp4.send(); } ``` Através dessa função obtém-se o estado atual da página de cada saída, isto é, a lâmpada está ligada ou desligada? O ar condicionado está ligado? Se sim, está configurado em qual temperatura? Dessa forma, a função é capaz de obter informações preliminares e atualizar o estado dos ícones do nosso web-server e dos seus dispositivos físicos. Uma outra função que vale a pena destacar e que se repete para as outras saídas do nosso projeto é a ```air.onclick = function()``` a seguir: ```c++ var air = document.getElementById('air'); var airStatus = air.checked ? "ON" : "OFF"; document.getElementById("airIcon").style.color = air.checked? "cornflowerblue" : "lightgray"; var slideAir = document.getElementById("slider11"); air.onclick = function() { console.log("Botao do ar clicado"); if (this.checked) { airStatus = "ON"; document.getElementById("airIcon").style.color = \"cornflowerblue\"; console.log("ON"); } else { airStatus = "OFF"; document.getElementById("airIcon").style.color = "lightgray"; console.log(\"OFF\");" } var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(\"Requisicao recebida\");" } }; xhttp.open("GET", "toggleAir?airStatus="+airStatus+"&airTemp="+slideAir.value, true); xhttp.send(); }; ``` Caso você não se recorde, em um primeiro momento comentamos sobre a função ``` void updateAir()```, responsável por verificar o status de airStatus e alterar o estado da saída, de forma física, certo? Na função ```air.onclick=function()```, veremos como alterar o valor de `airStatus` Antes de falar propriamente da função, é necessário criar um objeto responsável por ser o parâmetro que vai indicar o Status do ar condicionado. Inicialmente temos três objetos diferentes: `air`, `airStauts` e o `sliderAir` que informaram ao servidor se o ar condicionado está ligado e se sim, em qual temperatura ele se encontra. Nesse caso, a partir da função ```air.onclick=function()```, o usuário consegue interagir com o webserver (apertando o botão) e fazendo com que alguns parâmetros sejam alterados. Por exemplo, se o usuário clicar no botão que é uma caixa de seleção, a caixa ficará selecionada e o status da variável `airStatus` assumirá ON e a cor do objeto no ser será alterada. A partir de ```var xhttp = new XMLHttpRequest();```, acontece uma requisição do servidor ao cliente, que de forma assíncrona, atualiza as informações alteradas, sem que haja a necessidade de atualizar a página inteira. ```c++ slideAir.oninput = function() { console.log("Valor do ar mudado"); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(\"Requisicao recebida\");" } };" xhttp.open("GET", "toggleAir?airStatus="+airStatus+"&airTemp="+slideAir.value, true); xhttp.send(); }; ``` Para o funcionamento do ar condicionado em específico criamos uma nova função ```slideAir.oninput = function()``` que é responsável por passar informações ao servidor sobre o valor de temperatura e o status do ar condicionado quando o usuário deslizar o botão, selecionando uma temperatura em específico. Lembrando que, com a utilização do AJAX, as alterações são processadas de forma assíncrona. As demais funções utilizadas neste código, são funções padrão das bibliotecas e por motivos de simplificação, não serão explicadas. É possível configurar um apelido para o ip do seu servidor no seu computador como mostra a imagem a seguir: <p align="center"> <img width="400px" src="assets/host.png" alt="host"/> </p> Para fazer isso no Linux, basta adicionar uma linha no arquivo `/etc/hosts`: ```bash # Host addresses 127.0.0.1 localhost ... 192.168.100.234 automacao <-- Adicione essa linha ``` No windows, este arquivo está no diretório `C: > Windows > System32 > Drivers > etc`. <p align="center"> <img src="assets/circuit.gif" alt="circuito"/> </p> Neste webserver importamos alguns códigos externos de bibliotecas para estilização da página. Estes códigos estão hospedados na internet, isto faz com que nosso webserver exiba a página adequadamente apenas quando a rede que este ESP está conectado estiver com acesso à internet. Isto pode ser um problema se quisermos implementar um sistema em algum local com uma rede que não tem acesso a internet. Além disso, embora o webserver que criamos neste post não seja mais uma página estática, ele ainda é uma página única, sem redirecionamento para outras páginas. E se quiséssemos colocar mais páginas nesse webserver? Visando resolver este problema, podemos utilizar a memória flash do ESP com o objetivo de armazenar estes códigos e possíveis páginas sem depender do acesso à internet. Inclusive, o NodeMCU consegue criar o seu próprio ponto de acesso Wi-fi, sem a necessidade de estar conectado a uma rede com acesso a internet. Dessa forma, visando superar essas barreiras e necessidades de acesso a internet, no próximo post ensinaremos como armazenar códigos e páginas do seu projeto na memória flash e ainda, explicaremos, de forma detalhada, como criar o seu próprio ponto de acesso Wi-fi com o seu ESP. Caso tenha tido algum problema abra uma _issue_ clicando [aqui](https://github.com/PETEletricaUFBA/IoT/issues/new) > É importante saber que o uso de *web servers* não se restringe a esse projeto. Após a compreensão do que foi feito no post, experimente criar uma outra aplicação física e integrá-la a um web server. É possível, por exemplo, controlar todas as lâmpadas de sua casa ou um eletrodoméstico, ativar ou desativar alarme de segurança via navegador do seu celular ou computador.
SQL
UTF-8
2,301
3.078125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.1.1 -- https://www.phpmyadmin.net/ -- -- Servidor: 127.0.0.1 -- Tiempo de generación: 23-09-2021 a las 05:58:03 -- Versión del servidor: 10.4.20-MariaDB -- Versión de PHP: 7.3.29 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `parcial` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `marcas` -- CREATE TABLE `marcas` ( `id_marca` smallint(6) NOT NULL, `marca` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `productos` -- CREATE TABLE `productos` ( `id_producto` int(11) NOT NULL, `producto` varchar(50) NOT NULL, `id_marca` smallint(6) NOT NULL, `descripcion` varchar(100) NOT NULL, `precio_costo` decimal(8,2) NOT NULL, `precio_venta` decimal(8,2) NOT NULL, `existencia` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Índices para tablas volcadas -- -- -- Indices de la tabla `marcas` -- ALTER TABLE `marcas` ADD PRIMARY KEY (`id_marca`); -- -- Indices de la tabla `productos` -- ALTER TABLE `productos` ADD PRIMARY KEY (`id_producto`), ADD UNIQUE KEY `id_marca` (`id_marca`); -- -- AUTO_INCREMENT de las tablas volcadas -- -- -- AUTO_INCREMENT de la tabla `marcas` -- ALTER TABLE `marcas` MODIFY `id_marca` smallint(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT de la tabla `productos` -- ALTER TABLE `productos` MODIFY `id_producto` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- Restricciones para tablas volcadas -- -- -- Filtros para la tabla `productos` -- ALTER TABLE `productos` ADD CONSTRAINT `productos_ibfk_1` FOREIGN KEY (`id_marca`) REFERENCES `marcas` (`id_marca`) ON UPDATE CASCADE; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Java
UTF-8
3,219
1.820313
2
[]
no_license
package com.app.usertreatzasia.fragments; import android.content.Intent; import android.graphics.Paint; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.app.usertreatzasia.R; import com.app.usertreatzasia.fragments.abstracts.BaseFragment; import com.app.usertreatzasia.helpers.UIHelper; import com.app.usertreatzasia.ui.views.AnyTextView; import com.app.usertreatzasia.ui.views.TitleBar; import butterknife.BindView; import butterknife.ButterKnife; public class RedeemCouponFragment extends BaseFragment { @BindView(R.id.iv_couponImage) ImageView ivCouponImage; @BindView(R.id.txt_paid_type) AnyTextView txtPaidType; @BindView(R.id.txt_couponDetail) AnyTextView txtCouponDetail; @BindView(R.id.txtActualAmount) AnyTextView txtActualAmount; @BindView(R.id.txtAfterDiscount) AnyTextView txtAfterDiscount; @BindView(R.id.txt_expire_time) AnyTextView txtExpireTime; @BindView(R.id.txt_address) AnyTextView txtAddress; @BindView(R.id.txt_remaining_qty) AnyTextView txtRemainingQty; @BindView(R.id.img_barcode) ImageView imgBarcode; @BindView(R.id.txt_termsDetails) AnyTextView txtTermsDetails; private int ID; private String Type; public void setContent(int id, String type) { setID(id); setType(type); // return this; } public void setID(int ID) { this.ID = ID; } public void setType(String type) { Type = type; } public static RedeemCouponFragment newInstance() { return new RedeemCouponFragment(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_redeem_coupon, container, false); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); txtActualAmount.setPaintFlags(txtActualAmount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } @Override public void setTitleBar(TitleBar titleBar) { super.setTitleBar(titleBar); titleBar.hideButtons(); titleBar.showBackButton(); titleBar.showShareButtonEnd(new View.OnClickListener() { @Override public void onClick(View v) { String shareBody = getResources().getString(R.string.share_msg); Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ""); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share))); } }); } }
C++
GB18030
882
2.625
3
[]
no_license
#pragma once #include"ChunkSection.h" #include<vector> #include"Tools.h" class Baserender; class Chunk { public: Chunk(World& world, const mvec2i& location); bool makeMesh(); void load(); bool hasLoaded(); void setBlock(int x, int y, int z, ChunkBlock block); void setBlock(mvec3i location, ChunkBlock block); ChunkBlock getBlock(int x, int y, int z); ChunkBlock getBlock(mvec3i location); mvec2i_xz getLocation(); ChunkSection& getSection(int index); //صindexChunkSection(±) void drawChunks(Baserender& render); //Chunk void tryAddSection(int y); //̬Section private: bool outOfBounds(int x,int y,int z); std::vector<ChunkSection> mChunks; //һͼChunk洢chunksֱУ mvec2i mLocation; bool isLoaded = false; World* mpWorld; };
Markdown
UTF-8
3,336
2.921875
3
[]
no_license
# preprocessor exercise ## Step 0: setup You can create a project from scratch. That is, install dependent packages via their names. ``` npm init -y npm i node-sass --save-dev # for step 2 npm i jquery --save npm i parcel-bundler --save-dev # for step 3 npm i pug-cli --save-dev # for step 1 # edit package.json if you want ``` Or, simply use our `package.json`, which specifies dependent packages for you. Notice that only one of the following two commands is required. ``` npm i yarn # if you have it ``` ## Step 1: use pug, a better html * What's [Pug](https://pugjs.org/language/tags.html)? * Need no start tag/end tag. * Use indent to represent scope level. * Use css selector to create html tag. For example, `#container` in pug equals `<div id="container"></div>` in html. * Compile a pug file. ``` ./node_modules/.bin/pug ./app/index.pug -o ./dist/ ``` or use [npx](https://www.npmjs.com/package/npx): ``` npx pug ./app/index.pug -o ./dist/ ``` Compare `./app/index.pug` and `./dist/index.html`. * Insert a `<h2>Hello world!</h2>` equivalent into `./app/index.pug` and follow the instructions beginning with `Step 1`. In `vi`, try pressing `/` key to search text. Remember to re-compile once you edit `./app/index.pug`. * Feel tired to compile manually? Use `--watch`. ``` $ ./node_modules/.bin/pug ./app/index.pug -o ./dist/ --watch ``` The `./dist/index.html` will be automatically re-compiled whenever you save `./app/index.pug`. ## Step 2: use sass, a better css * What's [SASS](https://sass-lang.com/guide)? As pug, sass use indent to represent scope level and has many useful features. Try variables, nesting, and mixins. * Compile `./app/app.sass` to `./dist/app.css`. ``` $ ./node_modules/.bin/node-sass ./app/app.sass -o dist --watch ``` * Reference the following code to make the three buttons different with `buttonStyle` mixin. ``` /* Step 2: * copy the following code to `./app/app.sass` * you may need to copy more than once * replace [child index], [color] and [border radius] with appropriate values */ &:nth-child([child index]) +buttonStyle([color], [border radius]) ``` Compare `./app/app.sass` and `./dist/app.css`. ## Step 3: is there a better js? There was, see [Babel](https://babeljs.io/). However, modern js engines catch up the development of js. Try to open `./babel/es6.js` in old [Node.js](https://nodejs.org/en/) (version < 7) or browsers. Now Babel is usually used for js variants such as [TypeScript](https://www.typescriptlang.org/). Execute the following command and than compare `./babel/typescript.ts` and `./dist/typescript.js`. ``` $ ./node_modules/.bin/babel ./babel/typescript.ts --out-dir ./dist/ --extensions ".ts" ``` ## Step 4: automation (with parcel) * Using parcel, you can watch pug, sass and js together. ``` $ ./node_modules/.bin/parcel watch ./parcel/index.pug ``` Note that `./app/index.pug` links `app.css` but `./parcel/index.pug` links `app.sass`. * See `parcel/app.js` to learn how to use jquery with parcel. * Automation tools like parcel do more than just preprocessing. ``` $ ./node_modules/.bin/parcel ./parcel/index.pug --port [port] ``` Open `http://[host]:[port]` in your browser. Remember to replace [host] and [port] to appropriate values.
Java
UTF-8
2,297
1.945313
2
[ "Apache-2.0" ]
permissive
/* * Copyright 2020 Gunnar Hillert * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hillert.s1.plants.service.impl; import javax.validation.constraints.NotBlank; import com.univocity.parsers.annotations.Parsed; import com.univocity.parsers.annotations.Trim; public class CsvRow { @Trim @Parsed(index = 0) private Double latitude; @Trim @Parsed(index = 1) private Double longitude; @Trim @Parsed(index = 3) private String comments; @Trim @NotBlank @Parsed(index = 4) private String genus; @Trim @NotBlank @Parsed(index = 5) private String species; @Trim @Parsed(index = 6) private String imagePath; @Parsed(index = 8) private Boolean plantSignMissing; public Double getLatitude() { return latitude; } public void setLatitude(Double latitude) { this.latitude = latitude; } public Double getLongitude() { return longitude; } public void setLongitude(Double longitude) { this.longitude = longitude; } public String getComments() { return comments; } public void setComments(String comments) { this.comments = comments; } public String getGenus() { return genus; } public void setGenus(String genus) { this.genus = genus; } public String getSpecies() { return species; } public void setSpecies(String species) { this.species = species; } public String getImagePath() { return imagePath; } public void setImagePath(String imagePath) { this.imagePath = imagePath; } public Boolean getPlantSignMissing() { return plantSignMissing != null ? plantSignMissing : false; } public void setPlantSignMissing(Boolean plantSignMissing) { this.plantSignMissing = plantSignMissing; } @Override public String toString() { return "CsvRow [Genus=" + genus + ", species=" + species +"]"; } }
Python
UTF-8
664
3.25
3
[]
no_license
def kaprekarNumbers(p, q): h = [] for i in range(p, q+1): if (i == 1 ): h.append(i) elif (i ==2): continue elif (i == 3): continue else: d = len(str(i)) k = len(str(i**2)) sq = str(i*i) l = int ( sq[ : k-d] ) r = int ( sq[ k-d : ]) if (r + l == i): h.append(i) if len(h) == 0: print("INVALID RANGE") else: for i in h: print(i, end=" ") if __name__ == '__main__': p = int(input()) q = int(input()) kaprekarNumbers(p, q)
Java
UTF-8
2,242
2.484375
2
[]
no_license
package fr.naruse.tools.packets; import com.google.common.collect.Lists; import fr.naruse.servermanager.core.ServerManager; import fr.naruse.servermanager.core.connection.packet.IPacket; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.List; public class PacketTeleportToLocation implements IPacket { public PacketTeleportToLocation() { } private List<String> names; private Location location; private String world; public PacketTeleportToLocation(List<String> names, Location location, String world) { this.names = names; this.location = location; this.world = world; } @Override public void write(DataOutputStream dataOutputStream) throws IOException { dataOutputStream.writeInt(this.names.size()); for (int i = 0; i < this.names.size(); i++) { dataOutputStream.writeUTF(this.names.get(i)); } dataOutputStream.writeUTF(this.world); dataOutputStream.writeDouble(this.location.getX()); dataOutputStream.writeDouble(this.location.getY()); dataOutputStream.writeDouble(this.location.getZ()); dataOutputStream.writeFloat(this.location.getYaw()); dataOutputStream.writeFloat(this.location.getPitch()); } @Override public void read(DataInputStream dataInputStream) throws IOException { List<String> list = Lists.newArrayList(); int size = dataInputStream.readInt(); for(int i = 0; i < size; ++i) { list.add(dataInputStream.readUTF()); } this.names = list; World world = Bukkit.getWorld(dataInputStream.readUTF()); if(world == null){ return; } this.location = new Location(world, dataInputStream.readDouble(), dataInputStream.readDouble(), dataInputStream.readDouble(), dataInputStream.readFloat(), dataInputStream.readFloat()); } @Override public void process(ServerManager serverManager) { } public List<String> getNames() { return names; } public Location getLocation() { return location; } }
C#
UTF-8
880
3.21875
3
[]
no_license
using System.Collections.Generic; public class NodePath { private LinkedList<Node> path; private LinkedListNode<Node> target; public int Count { get { return path.Count; } } public List<Node> ListRepresentation { get { return new List<Node>(path); } } public Node Next { get { Node nextNode = target.Value; target = target.Next; return nextNode; } } public NodePath(LinkedList<Node> nodeSequence) { path = nodeSequence; target = path.First; } public NodePath(List<Node> nodeSequence) { path = new LinkedList<Node>(nodeSequence); target = path.First; } public bool HasNext() { return target != null; } public void Reset() { target = path.First; } }
C++
WINDOWS-1252
16,625
2.828125
3
[]
no_license
//#include "OdeloBattleSystem.h" //#include <stdio.h> // //typedef struct dostone{ // int x; // int y; // int score; // int reversenum; //}; // //int board[8][8]; //dostone stoneP[8][8]; //dostone temp; //int howmany2; //int count = 0; // // //BOOL isfirst = false; //int canStone(int , int ); //void reversestoneB(int, int); //void reversestoneW(int , int); // // //// 0 ĭ, 1 浹, 2 鵹 // //void BlackAttack( int *x, int *y ) //{ // ++count; // if(!(isfirst)){ // for(int i = 0; i<8; ++i){ // for(int j = 0; j<8; ++j){ // board[i][j] = 0; // } // } // board[3][3] = 1; // board[4][4] = 1; // board[3][4] = 2; // board[4][3] = 2; // // isfirst = true; // } // // for(int i = 0; i<8; ++i){ // for(int j = 0; j<8; ++j){ // //printf("%d\n", canStone(3, 3) ); // if(canStone(i, j ) == 1){ // if((i == 0 && j == 0) || (i == 0 && j ==7) || (i == 7 && j ==0) || (i == 7 && j ==7)){ // stoneP[i][j].score = 150; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // } // // else if(((i == 0 || i == 7) && (1<=j && j<=6))||((j == 0 || j == 7) && (1<=i && i<=6))){ // stoneP[i][j].score = 100; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // if((i==0 && (j== 1 || j == 6)) || (i== 1 &&( j==0 || j ==7)) || (i==7 && (j== 1 || j == 6)) || (i== 6 &&( j==0 || j ==7))){ // stoneP[i][j].score = 60; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // } // } // else if( (2<=i && i<= 5) && (2<=j && j<= 5) ){ // stoneP[i][j].score = 50; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // if( (i == 2 && i == 2) || (i == 2 && j == 5) || ( i == 5 && j == 2 ) || ( i == 5 && j == 5) ){ // stoneP[i][j].score = 70; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // } // } // else if( (i == 1 && j == 1) || (i == 1 && j == 6) || (i == 6 && j == 1) || (i == 6 && j == 6) ){ // stoneP[i][j].score = 1; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // } // else { // stoneP[i][j].score = 30; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // if((i==1 && (j== 2 || j == 5)) || (i== 2 &&( j==1 || j ==6)) || (i==5 && (j== 1 || j == 6)) || (i== 6 &&( j==2 || j ==5))){ // stoneP[i][j].score = 40; // stoneP[i][j].x = j; // stoneP[i][j].y = i; // stoneP[i][j].reversenum = howmany2-1; // } // } // } // } // } // howmany2 = 0; // // temp.score = 0; // // for(int i = 0; i<8; ++i){ // for(int j = 0; j<8; ++j){ // if(temp.score <= stoneP[i][j].score){ // temp.score = stoneP[i][j].score; // temp.x = stoneP[i][j].x; // temp.y = stoneP[i][j].y; // } // else if(temp.score == stoneP[i][j].score){ // if(temp.reversenum <= stoneP[i][j].reversenum){ // temp.reversenum = stoneP[i][j].reversenum; // temp.x = stoneP[i][j].x; // temp.y = stoneP[i][j].y; // } // else if(temp.reversenum > stoneP[i][j].reversenum){ // //temp2.x = temp2.x; // //temp2.y = temp2.y; // } // // } // } // } // // printf( " %d, %d\n", temp.x,temp.y ); // // *x = temp.x; // *y = temp.y; // // for(int i = 0; i<8; ++i){ // for(int j = 0; j<8; ++j){ // stoneP[i][j].score = 0; // stoneP[i][j].x = 0; // stoneP[i][j].y = 0; // // } // } // board[temp.y][temp.x] = 1; // reversestoneB(temp.y,temp.x ); // // temp.score = 0; // temp.x = 0; // temp.y = 0; // // for(int i = 0; i<8; ++i){ // for(int j = 0; j<8; ++j){ // printf( "%d ", board[i][j] ); // } // printf("\n"); // } //} // //void BlackDefence( int x, int y ){ // board[y][x] = 2; // reversestoneW(y, x); //} // //int canStone(int y, int x){ // if(board[y][x] == 0){ // for(int k=-1; k<=1; ++k){ // for(int l=-1;l<=1; ++l){ // if(board[y+k][x+l]== 2){ // int sigx = x+l; // int sigy = y+k; // int n = 0; // while(n<8){ // if(sigx <= -1 || sigx >=8 || sigy <= -1 || sigy >=8){ // // break; // } // if(board[sigy][sigx]==1){ // return 1; // break; // } // // else if(board[sigy][sigx]!=2 || board[sigy][sigx]==0){ // // break; // // } // // else if(n==7){ // // break; // // } // sigy+=k; // sigx+=l; // n+=1; // howmany2 = n; // } // // // // } // // else if(k==1 && l==1) // return 0; // } // } // } // // //} // // //void reversestoneB(int y, int x){ // // for(int k=-1; k<=1; ++k){ // for(int l=-1;l<=1; ++l){ // if(board[y+k][x+l]==2){ // int sigx = x+l; // int sigy = y+k; // int n = 0; // while(n<7){ // if(sigx <= -1 || sigx >=8 || sigy <= -1 || sigy >=8){ // break; // } // if(board[sigy][sigx]==1){ // while(n>0){ // if(sigy == y && sigx == x){ // break; // } // else if(n==0){ // break; // } // // board[sigy-k][sigx-l] = 1; // sigy-=k; // sigx-=l; // n-=1; // } // // // break; // } // else if(board[sigy][sigx]!=2){ // break; // } // // else if(n==6){ // // break; // } // // sigy+=k; // sigx+=l; // n+=1; // } // // // // } // // else if(k==1 && l==1) // return; // } // } //} // //void reversestoneW(int y, int x){ // // for(int k=-1; k<=1; ++k){ // for(int l=-1;l<=1; ++l){ // if(board[y+k][x+l]==1){ // int sigx = x+l; // int sigy = y+k; // int n = 0; // while(n<7){ // if(sigx <= -1 || sigx >=8 || sigy <= -1 || sigy >=8){ // break; // } // if(board[sigy][sigx]==2){ // while(n>0){ // if(sigy == y && sigx == x){ // break; // } // else if(n==0){ // break; // } // // board[sigy-k][sigx-l] = 2; // sigy-=k; // sigx-=l; // n-=1; // } // // // break; // } // else if(board[sigy][sigx]!=1){ // break; // } // // else if(n==6){ // // break; // } // // sigy+=k; // sigx+=l; // n+=1; // } // // // // } // // else if(k==1 && l==1) // return; // } // } //} // #include "OdeloBattleSystem.h" #include <stdio.h> typedef struct dostone{ int x; int y; int score; int reversenum; }; int board[8][8]; dostone stoneP[8][8]; dostone temp; int howmany2; int count = 0; BOOL isfirst = false; int canStone(int , int ); void reversestoneB(int, int); void reversestoneW(int , int); // 0 ĭ, 1 浹, 2 鵹 void BlackAttack( int *x, int *y ) { ++count; if(!(isfirst)){ for(int i = 0; i<8; ++i){ for(int j = 0; j<8; ++j){ board[i][j] = 0; } } board[3][3] = 1; board[4][4] = 1; board[3][4] = 2; board[4][3] = 2; isfirst = true; } for(int i = 0; i<8; ++i){ for(int j = 0; j<8; ++j){ //printf("%d\n", canStone(3, 3) ); if(canStone(i, j ) == 1){ if((i == 0 && j == 0) || (i == 0 && j ==7) || (i == 7 && j ==0) || (i == 7 && j ==7)){ stoneP[i][j].score = 150; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; } else if(((i == 0 || i == 7) && (1<=j && j<=6))||((j == 0 || j == 7) && (1<=i && i<=6))){ stoneP[i][j].score = 80; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; if((i==0 && (j== 1 || j == 6)) || (i== 1 &&( j==0 || j ==7)) || (i==7 && (j== 1 || j == 6)) || (i== 6 &&( j==0 || j ==7))){ stoneP[i][j].score = 60; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; } } else if( (2<=i && i<= 5) && (2<=j && j<= 5) ){ stoneP[i][j].score = 50; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; if(count <= 7){ stoneP[i][j].score = 110; } if( (i == 2 && i == 2) || (i == 2 && j == 5) || ( i == 5 && j == 2 ) || ( i == 5 && j == 5) ){ stoneP[i][j].score = 70; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; if(count <= 7){ stoneP[i][j].score = 120; } } } else if( (i == 1 && j == 1) || (i == 1 && j == 6) || (i == 6 && j == 1) || (i == 6 && j == 6) ){ stoneP[i][j].score = 1; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; if( board[0][0]!=0 && board[0][7] != 0 && board[7][0] != 0 && board[7][7] != 0){ stoneP[i][j].score = 150; } } else { stoneP[i][j].score = 90; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; if((i==1 && (j== 2 || j == 5)) || (i== 2 &&( j==1 || j ==6)) || (i==5 && (j== 1 || j == 6)) || (i== 6 &&( j==2 || j ==5))){ stoneP[i][j].score = 100; stoneP[i][j].x = j; stoneP[i][j].y = i; stoneP[i][j].reversenum = howmany2-1; } } } } } howmany2 = 0; temp.score = 0; for(int i = 0; i<8; ++i){ for(int j = 0; j<8; ++j){ if(temp.score <= stoneP[i][j].score){ temp.score = stoneP[i][j].score; temp.x = stoneP[i][j].x; temp.y = stoneP[i][j].y; } //else if(temp.score == stoneP[i][j].score){ // if(temp.reversenum <= stoneP[i][j].reversenum){ // temp.reversenum = stoneP[i][j].reversenum; // temp.x = stoneP[i][j].x; // temp.y = stoneP[i][j].y; // } // else if(temp.reversenum > stoneP[i][j].reversenum){ // //temp2.x = temp2.x; // //temp2.y = temp2.y; // } // //} } } printf( " %d, %d\n", temp.x,temp.y ); *x = temp.x; *y = temp.y; for(int i = 0; i<8; ++i){ for(int j = 0; j<8; ++j){ stoneP[i][j].score = 0; stoneP[i][j].x = 0; stoneP[i][j].y = 0; } } board[temp.y][temp.x] = 1; reversestoneB(temp.y,temp.x ); temp.score = 0; temp.x = 0; temp.y = 0; for(int i = 0; i<8; ++i){ for(int j = 0; j<8; ++j){ printf( "%d ", board[i][j] ); } printf("\n"); } } void BlackDefence( int x, int y ){ board[y][x] = 2; reversestoneW(y, x); } int canStone(int y, int x){ if(board[y][x] == 0){ for(int k=-1; k<=1; ++k){ for(int l=-1;l<=1; ++l){ if(board[y+k][x+l]== 2){ int sigx = x+l; int sigy = y+k; int n = 0; while(n<8){ if(sigx <= -1 || sigx >=8 || sigy <= -1 || sigy >=8){ break; } if(board[sigy][sigx]==1){ return 1; break; } else if(board[sigy][sigx]!=2 || board[sigy][sigx]==0){ break; } else if(n==7){ break; } sigy+=k; sigx+=l; n+=1; howmany2 = n; } } else if(k==1 && l==1) return 0; } } } } void reversestoneB(int y, int x){ for(int k=-1; k<=1; ++k){ for(int l=-1;l<=1; ++l){ if(board[y+k][x+l]==2){ int sigx = x+l; int sigy = y+k; int n = 0; while(n<7){ if(sigx <= -1 || sigx >=8 || sigy <= -1 || sigy >=8){ break; } if(board[sigy][sigx]==1){ while(n>0){ if(sigy == y && sigx == x){ break; } else if(n==0){ break; } board[sigy-k][sigx-l] = 1; sigy-=k; sigx-=l; n-=1; } break; } else if(board[sigy][sigx]!=2){ break; } else if(n==6){ break; } sigy+=k; sigx+=l; n+=1; } } else if(k==1 && l==1) return; } } } void reversestoneW(int y, int x){ for(int k=-1; k<=1; ++k){ for(int l=-1;l<=1; ++l){ if(board[y+k][x+l]==1){ int sigx = x+l; int sigy = y+k; int n = 0; while(n<7){ if(sigx <= -1 || sigx >=8 || sigy <= -1 || sigy >=8){ break; } if(board[sigy][sigx]==2){ while(n>0){ if(sigy == y && sigx == x){ break; } else if(n==0){ break; } board[sigy-k][sigx-l] = 2; sigy-=k; sigx-=l; n-=1; } break; } else if(board[sigy][sigx]!=1){ break; } else if(n==6){ break; } sigy+=k; sigx+=l; n+=1; } } else if(k==1 && l==1) return; } } }
JavaScript
UTF-8
3,040
3.359375
3
[]
no_license
function mostrar() { var numeroUno; var numeroDos; numeroUno=prompt("Ingrese el primer numero"); numeroUno=parseInt(numeroUno); numeroDos=prompt("Ingrese el segundo numero"); numeroDos=parseInt(numeroDos); if(numeroUno==numeroDos) { mensaje=(numeroUno+" y "+numeroDos); }else { if(numeroUno>numeroDos) { mensaje=numeroUno/numeroDos; }else { if(numeroUno<numeroDos) { mensaje=numeroUno+numeroDos if(mensaje<50) { mensaje=("la suma es "+mensaje+" y es menor a 50"); } } } } alert(mensaje); /* var importeUno; var importeDos; var importeTres; var importeCuatro; var sumaCuatroImportes; var menosDiezPorCiento; var menosCincoPorCiento; var masQuincePorCiento; var mensajeDos; importeUno=prompt("ingrese el primer importe"); importeDos=prompt("ingrese el segundo importe"); importeTres=prompt("ingrese el tercer importe"); importeCuatro=prompt("ingrese el cuarto importe"); importeUno=parseInt(importeUno); importeDos=parseInt(importeDos); importeTres=parseInt(importeTres); importeCuatro=parseInt(importeCuatro); sumaCuatroImportes=importeUno+importeDos+importeTres+importeCuatro; menosDiezPorCiento=sumaCuatroImportes*0.9 menosCincoPorCiento=sumaCuatroImportes*0.95 masQuincePorCiento=sumaCuatroImportes*1.15 if(sumaCuatroImportes>=100) { mensaje=("su total es "+sumaCuatroImportes+" y tiene un descuento del 10%, su total es " +menosDiezPorCiento); }else if(sumaCuatroImportes>=50 && sumaCuatroImportes<=99) { mensaje=("su total es "+sumaCuatroImportes+" y tiene un descuento del 5%, su total es " +menosCincoPorCiento); }else{ mensaje=("su total es "+sumaCuatroImportes+" y tiene una recarga del 15%, su total es " +masQuincePorCiento); } if(importeUno>importeDos && importeUno>importeTres && importeUno>importeCuatro) { mensajeDos=("el mayor importe es " +importeUno+""); }else if(importeDos>importeUno && importeDos>importeTres && importeDos>importeCuatro) { mensajeDos=("el mayor importe es " +importeDos+""); }else if(importeTres>importeUno && importeTres>importeDos && importeTres>importeCuatro) { mensajeDos=("el mayor importe es "+importeTres+""); }else if(importeCuatro>importeUno && importeCuatro>importeDos && importeCuatro>importeTres) { mensajeDos=("el mayor importe es "+importeCuatro+""); }else { mensajeDos=("el mayor importe es "+importeUno+""); } alert(mensajeDos+" y "+mensaje); /* var numeroUno; var numeroDos; var suma; var resta; var concatenado; numeroUno=prompt("Ingrese el primer numero"); numeroDos=prompt("Ingrese el segundo numero"); numeroUno=parseInt(numeroUno); numeroDos=parseInt(numeroDos); suma=numeroUno+numeroDos; resta=numeroUno-numeroDos; concatenado=(""+numeroUno+" y "+numeroDos); if(numeroUno==numeroDos) { mensaje=concatenado; }else if(numeroUno>numeroDos) { mensaje=resta; }else{ mensaje=suma; if(suma>10) { mensaje=("la suma es "+suma+" y superó el 10"); } } alert(mensaje); */ }
C#
UTF-8
6,546
2.609375
3
[]
no_license
using Microsoft.Extensions.Configuration; using RentCar.Core.Helpers; using RentCar.Core.Interfaces; using RentCar.Core.Models; using System; using System.Collections.Generic; using System.Data; using System.Text; namespace RentCar.Core.Datebase { public class CustomerDB : BaseDB, ICustomerDB { public CustomerDB(IConfiguration configuration) : base(configuration) { } public Customer AddOrUpdate(Customer customer) { db.OpenConnection(); var cmd = db.CreateCommandStoredProcedure("sp_CustomerAddOrUpdate"); db.InOutParameter(cmd, "@Id", DbType.Int32, customer.Id); db.StringParameter(cmd, "@FirstName", customer.FirstName); db.StringParameter(cmd, "@LastName", customer.LastName); db.StringParameter(cmd, "@Caption", customer.Caption); db.StringParameter(cmd, "@IdentityNumber", customer.IdentityNumber); db.DateParameter(cmd, "@Birthdate", customer.Birthdate); db.IntegerParameter(cmd, "@Gender", (int)customer.Gender); db.StringParameter(cmd, "@TaxNumber", customer.TaxNumber); db.StringParameter(cmd, "@TaxOffice", customer.TaxOffice); db.StringParameter(cmd, "@Mobile", customer.Mobile); db.StringParameter(cmd, "@HomePhone", customer.HomePhone); db.StringParameter(cmd, "@OfficePhone", customer.OfficePhone); db.IntegerParameter(cmd, "@CityId", customer.CityId); db.StringParameter(cmd, "@Address", customer.Address); db.BooleanParameter(cmd, "@IsActive", customer.IsActive); cmd.ExecuteNonQuery(); if (cmd.Parameters["@Id"].Value != DBNull.Value) customer.Id = Convert.ToInt32(cmd.Parameters["@Id"].Value); return customer; } public Customer Get(Customer customer) { Customer result = null; db.OpenConnection(); var cmd = db.CreateCommandStoredProcedure("sp_CustomerGetDetail"); db.IntegerParameter(cmd, "@Id", customer.Id); using (var dr = cmd.ExecuteReader()) { if (dr.Read()) { result = new Customer { Id = Convert.ToInt32(dr["Id"]), FirstName = dr["FirstName"].ToString(), LastName = dr["LastName"].ToString(), Caption = dr["Caption"].ToString(), IdentityNumber = dr["IdentityNumber"].ToString(), Birthdate = Convert.ToDateTime(dr["Birthdate"]), Gender = dr["Gender"].ToString().ToEnum<Gender>(), TaxNumber = dr["TaxNumber"].ToString(), TaxOffice = dr["TaxOffice"].ToString(), Mobile = dr["Mobile"].ToString(), HomePhone = dr["HomePhone"].ToString(), OfficePhone = dr["OfficePhone"].ToString(), CityId = Convert.ToInt32(dr["CityId"]), City = new City { Id = Convert.ToInt32(dr["CityId"]), Name = dr["CityName"].ToString() }, StateId = Convert.ToInt32(dr["StateId"]), State = new State { Id = Convert.ToInt32(dr["StateId"]), Name = dr["StateName"].ToString() }, Address = dr["Address"].ToString(), IsActive = Convert.ToBoolean(dr["IsActive"]) }; } } return result; } public List<Customer> List(Customer customer) { List<Customer> list = new List<Customer>(); Customer item; db.OpenConnection(); var cmd = db.CreateCommandStoredProcedure("sp_CustomerGetList"); db.StringParameter(cmd, "@FirstName", customer.FirstName); db.StringParameter(cmd, "@LastName", customer.LastName); db.StringParameter(cmd, "@Caption", customer.Caption); db.StringParameter(cmd, "@Mobile", customer.Mobile); db.StringParameter(cmd, "@HomePhone", customer.HomePhone); db.StringParameter(cmd, "@OfficePhone", customer.OfficePhone); db.BooleanParameter(cmd, "@IsActive", customer.IsActive); using (var dr = cmd.ExecuteReader()) { while (dr.Read()) { item = new Customer { Id = Convert.ToInt32(dr["Id"]), FirstName = dr["FirstName"].ToString(), LastName = dr["LastName"].ToString(), Caption = dr["Caption"].ToString(), IdentityNumber = dr["IdentityNumber"].ToString(), Birthdate = Convert.ToDateTime(dr["Birthdate"]), Gender = dr["Gender"].ToString().ToEnum<Gender>(), TaxNumber = dr["TaxNumber"].ToString(), TaxOffice = dr["TaxOffice"].ToString(), Mobile = dr["Mobile"].ToString(), HomePhone = dr["HomePhone"].ToString(), OfficePhone = dr["OfficePhone"].ToString(), CityId = Convert.ToInt32(dr["CityId"]), City =new City { Id = Convert.ToInt32(dr["CityId"]), Name = dr["CityName"].ToString() }, StateId = Convert.ToInt32(dr["StateId"]), State=new State { Id = Convert.ToInt32(dr["StateId"]), Name = dr["StateName"].ToString() }, Address= dr["Address"].ToString(), IsActive = Convert.ToBoolean(dr["IsActive"]), }; list.Add(item); } } return list; } public bool Delete(int id) { throw new NotImplementedException(); } } }
Swift
UTF-8
2,533
2.65625
3
[]
no_license
// // Endpoints.swift // ios-test // // Created by Huseyn Bayramov on 7/18/20. // Copyright © 2020 Apple. All rights reserved. // import Alamofire import CoreData class Endpoints { private init() {} static let shared = Endpoints() private var manager: Alamofire.Session = { let conf = URLSessionConfiguration.default conf.timeoutIntervalForResource = 60 let manager = Alamofire.Session(configuration: conf) return manager }() typealias categoryResponse = (AppResponse<Response<[Category]>>) -> () typealias paymentResponse = (AppResponse<Response<Receipt>>) -> () func getCategories(completion: @escaping categoryResponse) { print("Get categories endpoint called") customRequest(to: Router.getCategories) { completion($0) } } func makeNewPayment(body: String, completion: @escaping paymentResponse) { print("Make new payment endpoint called") customRequest(to: Router.makeNewPayment(body: body)) { completion($0) } } } extension Endpoints { private func customRequest<T: Decodable>(to route: Router, completion: @escaping (AppResponse<T>) -> ()) { manager.request(route).validate(statusCode: 200..<600).responseJSON { response in let decoder = JSONDecoder() let response = decoder.decodeResponse(T.self, response: response) completion(response) } } } extension JSONDecoder { func decodeResponse<T: Decodable>(_ type: T.Type, response: AFDataResponse<Any>) -> AppResponse<T> { switch response.result { case .failure(let error): if error._code == NSURLErrorTimedOut { return .failure(.responseError("Time out")) } if error._code == NSURLErrorNotConnectedToInternet { return .failure(.notConnectedToInternet) } return .failure(.responseError("Please, call the support.")) case .success(_): if let data = response.data { nonConformingFloatDecodingStrategy = .throw do { let result = try decode(type.self, from: data) return .success(result) } catch { print("parsing error \(error)") return .failure(.responseError("No Data Found")) } } else { return .failure(.noData("No Data Found")) } } } }
Markdown
UTF-8
743
3.359375
3
[]
no_license
## Spark Functions ### Element-wise transformation - `map()` - transform each element to a new value - `filter()` - takes in a function and returns an RDD that only has elements that pass the `filter()` function - `flatmap()` - we use it when we want to produce multiple output elements for each input element. ```java JavaRDD<String> lines = sc.parallelize(Arrays.asList("hello world", "hi")); JavaRDD<String> words = lines.flatMap(new FlatMapFunction<String, String>(){ public Iterable<String> call(String line){ return Arrays.asList(line.split(" ")); } }); words.first ``` - `distinct()` - remove duplicates - `foreach(func)` - apply the provided function to each element of the RDD - return nothing
Python
UTF-8
601
3.1875
3
[]
no_license
from typing import List, Tuple def solve(start: int, schedule: List[int]) -> int: p = min(schedule, key=lambda p: (start + p - 1) // p * p) return p * ((start + p - 1) // p * p - start) def parse(text: str) -> Tuple[int, List[int]]: line1, line2 = text.split() return int(line1), [int(s) for s in line2.split(',') if s != 'x'] def test_solve(): assert solve(*parse("""939 7,13,x,x,59,x,31,19""")) == 295 def main(): with open('day13.txt') as f: start, schedule = parse(f.read().strip()) print(solve(start, schedule)) if __name__ == '__main__': main()
PHP
UTF-8
2,394
2.96875
3
[]
no_license
<?php namespace Etech\Classes; class Database extends \PDO { private $dbh, $queryCount; public function __construct() { try { parent::__construct("mysql:host=" . HOST .";port=" . DB_PORT . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD); } catch(\Exception $e) { echo $e->getMessage(); } } public function query($query, $fields = NULL, $fetchType = "ALL", $fetchMode = \PDO::FETCH_OBJ) { $this->queryCount++; $getType = explode(" ", $query); $type = strtoupper($getType[0]); switch($type) { case "SELECT": return $this->selectQuery($query,$fields,$fetchType,$fetchMode); break; case "INSERT": return $this->insertQuery($query,$fields); break; case "UPDATE": return $this->updateQuery($query,$fields); break; case "DELETE": return $this->deleteQuery($query,$fields); break; default: return $this->defaultQuery($query); } } protected function defaultQuery($query) { $STH = parent::query($query); } public function insertQuery($query, $fields) { try { $STH = $this->prepare($query); $STH->execute($fields); return $this->lastInsertId("id"); } catch(PDOException $e) { echo $e->getMessage(); foreach ($fields AS $field=>$value) { $query = str_replace(":{$field}", "'{$value}'", $query); } echo $query; } } public function getQueryCount() { return $this->queryCount; } public function insert($table, $fields) { $query = "INSERT INTO " . $table . " (" . implode(",", array_keys($fields)) . ") VALUES (:" . implode(",:", array_keys($fields)) . ")"; return $this->query($query, $fields); } public function updateQuery($query, $fields) { $STH = $this->prepare($query); $STH->execute($fields); } public function selectQuery($query, $fields, $fetchType = "ALL", $fetchMode = \PDO::FETCH_OBJ) { /*foreach ($fields AS $field=>$value) { $query = str_replace(":{$field}", "'{$value}'", $query); } echo $query;*/ try { $STH = $this->prepare($query); $STH->execute($fields); } catch(PDOException $e) { echo $e->getMessage(); } $STH->setFetchMode($fetchMode); if($fetchType == "ALL") { return $STH->fetchAll(); } else { return $STH->fetch(); } } public function deleteQuery($query,$fields) { $STH = $this->prepare($query); $STH->execute($fields); } }
Markdown
UTF-8
169,262
3.125
3
[]
no_license
## 作业一     作业要求:使用GCLogAnalysis.java 自己演练一遍串行/并行/CMS/G1的案例。     用于测试的代码如下: ```java package cn.qj.week2; import java.util.Random; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.LongAdder; /** * GC日志生成演示与解读 */ public class GCLogAnalysis { private static Random random = new Random(); public static void main(String[] args) { // 当前毫秒时间戳 long startMillis = System.currentTimeMillis(); // 持续运行毫秒数,可根据需要进行修改 long timeoutMillis = TimeUnit.SECONDS.toMillis(1); // 结束时间戳 long endMillis = startMillis + timeoutMillis; LongAdder counter = new LongAdder(); System.out.println("正在执行"); // 缓存一部分对象,进入老年代 int cacheSize = 2000; Object[] cacheGarbege = new Object[cacheSize]; // 在此时间范围内,持续循环 // while (true) { while (System.currentTimeMillis() < endMillis) { // 生成垃圾对象 Object garbage = generateGarbage(100 * 1024); counter.increment(); int randomIndex = random.nextInt(2 * cacheSize); if (randomIndex < cacheSize) { cacheGarbege[randomIndex] = garbage; } // System.out.println("执行中! 共生成对象次数:" + counter.longValue()); } System.out.println("执行结束! 共生成对象次数:" + counter.longValue()); } /** * 生成对象 * @param maxSize * @return */ private static Object generateGarbage(int maxSize) { int randomSize = random.nextInt(maxSize); int type = randomSize % 4; Object result = null; switch (type) { case 0: result = new int[randomSize]; break; case 1: result = new byte[randomSize]; break; case 2: result = new double[randomSize]; break; default: StringBuilder builder = new StringBuilder(); String randomString = "randomString-Anything"; while (builder.length() < randomSize) { builder.append(randomString); builder.append(maxSize); builder.append(randomSize); } result = builder.toString(); break; } return result; } } ``` 分别按照堆大小256M, 512M, 1G, 2G, 4G 五种规格对串行GC,并行GC,CMS GC和G1 GC进行GC日志的记录和分析。 测试 ``` cd /Users/qianjiang/tmp/JAVA-000/Week_02/Learning_notes java GCLogAnalysis.java ``` 串行GC,并行GC,CMS GC和G1 GC 命令集 ``` #串行GC java -XX:+UseSerialGC -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseSerialGC -Xms512m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseSerialGC -Xms1g -Xmx1g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseSerialGC -Xms2g -Xmx2g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseSerialGC -Xms4g -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseSerialGC -Xms8g -Xmx8g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis #并行GC java -XX:+UseParallelGC -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseParallelGC -Xms512m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseParallelGC -Xms1g -Xmx1g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseParallelGC -Xms2g -Xmx2g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseParallelGC -Xms4g -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseParallelGC -Xms8g -Xmx8g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis #CMS GC java -XX:+UseConcMarkSweepGC -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseConcMarkSweepGC -Xms512m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseConcMarkSweepGC -Xms1g -Xmx1g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseConcMarkSweepGC -Xms2g -Xmx2g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseConcMarkSweepGC -Xms4g -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseConcMarkSweepGC -Xms8g -Xmx8g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis #G1 GC java -XX:+UseG1GC -Xms256m -Xmx256m -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseG1GC -Xms512m -Xmx512m -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseG1GC -Xms1g -Xmx1g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseG1GC -Xms2g -Xmx2g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseG1GC -Xms4g -Xmx4g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis java -XX:+UseG1GC -Xms8g -Xmx8g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis ``` ## 串行GC日志 ### 256M堆内存 串行GC日志: ``` ➜ Learning_notes (main) ✗ java -XX:+UseSerialGC -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:23:25.590-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.590-0800: [DefNew: 69523K->8703K(78656K), 0.0147241 secs] 69523K->25538K(253440K), 0.0147633 secs] [Times: user=0.02 sys=0.01, real=0.01 secs] 2020-10-28T17:23:25.620-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.620-0800: [DefNew: 78655K->8698K(78656K), 0.0202195 secs] 95490K->49508K(253440K), 0.0202546 secs] [Times: user=0.02 sys=0.01, real=0.02 secs] 2020-10-28T17:23:25.653-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.654-0800: [DefNew: 78249K->8703K(78656K), 0.0183657 secs] 119059K->77990K(253440K), 0.0183994 secs] [Times: user=0.02 sys=0.01, real=0.02 secs] 2020-10-28T17:23:25.685-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.685-0800: [DefNew: 78655K->8702K(78656K), 0.0168851 secs] 147942K->104716K(253440K), 0.0169194 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 2020-10-28T17:23:25.713-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.713-0800: [DefNew: 78634K->8699K(78656K), 0.0127064 secs] 174648K->124778K(253440K), 0.0127419 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:25.737-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.737-0800: [DefNew: 78651K->8701K(78656K), 0.0137780 secs] 194730K->146019K(253440K), 0.0138133 secs] [Times: user=0.00 sys=0.01, real=0.02 secs] 2020-10-28T17:23:25.764-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.764-0800: [DefNew: 78552K->8701K(78656K), 0.0148442 secs] 215871K->168729K(253440K), 0.0148833 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:25.790-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.790-0800: [DefNew: 78470K->78470K(78656K), 0.0000174 secs]2020-10-28T17:23:25.790-0800: [Tenured: 160028K->168148K(174784K), 0.0273177 secs] 238499K->168148K(253440K), [Metaspace: 2677K->2677K(1056768K)], 0.0273971 secs] [Times: user=0.02 sys=0.01, real=0.02 secs] 2020-10-28T17:23:25.829-0800: [GC (Allocation Failure) 2020-10-28T17:23:25.829-0800: [DefNew: 69952K->69952K(78656K), 0.0000248 secs]2020-10-28T17:23:25.829-0800: [Tenured: 168148K->174530K(174784K), 0.0306244 secs] 238100K->183967K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0307317 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:23:25.874-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:25.874-0800: [Tenured: 174530K->174767K(174784K), 0.0251847 secs] 253080K->196290K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0252295 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 2020-10-28T17:23:25.908-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:25.908-0800: [Tenured: 174767K->174498K(174784K), 0.0305577 secs] 253361K->198951K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0306070 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:23:25.949-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:25.949-0800: [Tenured: 174498K->174563K(174784K), 0.0094760 secs] 253033K->215564K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0095213 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:25.966-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:25.966-0800: [Tenured: 174563K->174701K(174784K), 0.0210364 secs] 252970K->222675K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0210834 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 2020-10-28T17:23:25.992-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:25.992-0800: [Tenured: 174701K->174608K(174784K), 0.0272270 secs] 253097K->227058K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0272695 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 2020-10-28T17:23:26.024-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.024-0800: [Tenured: 174717K->174750K(174784K), 0.0362003 secs] 253339K->221893K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0362428 secs] [Times: user=0.03 sys=0.00, real=0.04 secs] 2020-10-28T17:23:26.065-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.065-0800: [Tenured: 174750K->174750K(174784K), 0.0085905 secs] 253378K->234123K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0086385 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.078-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.078-0800: [Tenured: 174750K->174750K(174784K), 0.0080415 secs] 253289K->239222K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0080859 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.089-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.089-0800: [Tenured: 174750K->174508K(174784K), 0.0156915 secs] 253403K->240569K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0157350 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 2020-10-28T17:23:26.107-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.107-0800: [Tenured: 174758K->174394K(174784K), 0.0372432 secs] 253413K->233744K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0372812 secs] [Times: user=0.04 sys=0.00, real=0.04 secs] 2020-10-28T17:23:26.148-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.148-0800: [Tenured: 174394K->174394K(174784K), 0.0086780 secs] 252814K->237987K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0087272 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.159-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.159-0800: [Tenured: 174394K->174394K(174784K), 0.0104733 secs] 252771K->242142K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0105157 secs] [Times: user=0.01 sys=0.00, real=0.02 secs] 2020-10-28T17:23:26.172-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.172-0800: [Tenured: 174394K->174394K(174784K), 0.0116103 secs] 252959K->245297K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0116519 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.186-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.186-0800: [Tenured: 174394K->174579K(174784K), 0.0336228 secs] 252963K->239988K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0336684 secs] [Times: user=0.03 sys=0.00, real=0.04 secs] 2020-10-28T17:23:26.223-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.223-0800: [Tenured: 174714K->174714K(174784K), 0.0060487 secs] 253364K->242274K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0060925 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.232-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.232-0800: [Tenured: 174750K->174750K(174784K), 0.0062851 secs] 253385K->244672K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0063319 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.240-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.240-0800: [Tenured: 174750K->174750K(174784K), 0.0094016 secs] 252672K->247678K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0094782 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.250-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.250-0800: [Tenured: 174750K->174677K(174784K), 0.0347806 secs] 253392K->245049K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0348206 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:23:26.287-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.287-0800: [Tenured: 174677K->174677K(174784K), 0.0088048 secs] 253324K->247154K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0088507 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.298-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.298-0800: [Tenured: 174677K->174677K(174784K), 0.0081933 secs] 253016K->248756K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0082435 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.307-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.307-0800: [Tenured: 174763K->174763K(174784K), 0.0043532 secs] 253391K->248905K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0043912 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.312-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.312-0800: [Tenured: 174763K->174755K(174784K), 0.0354132 secs] 253397K->246739K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0354533 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:23:26.349-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.349-0800: [Tenured: 174755K->174755K(174784K), 0.0032508 secs] 253409K->247637K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0032885 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.353-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.353-0800: [Tenured: 174755K->174755K(174784K), 0.0100977 secs] 253036K->248152K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0101773 secs] [Times: user=0.01 sys=0.01, real=0.01 secs] 2020-10-28T17:23:26.364-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.365-0800: [Tenured: 174755K->174755K(174784K), 0.0068505 secs] 253089K->249480K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0068959 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.372-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.372-0800: [Tenured: 174755K->174752K(174784K), 0.0332135 secs] 253266K->249623K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0332541 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:23:26.407-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.407-0800: [Tenured: 174752K->174752K(174784K), 0.0095642 secs] 253321K->250144K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0096067 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.417-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.417-0800: [Tenured: 174752K->174752K(174784K), 0.0020461 secs] 253344K->251368K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0020819 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.420-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.420-0800: [Tenured: 174752K->174752K(174784K), 0.0082506 secs] 253160K->252208K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0082881 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.428-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.428-0800: [Tenured: 174752K->174209K(174784K), 0.0305218 secs] 253401K->250911K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0305963 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:23:26.460-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.460-0800: [Tenured: 174209K->174209K(174784K), 0.0065341 secs] 252322K->251072K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0065778 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.467-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.467-0800: [Tenured: 174551K->174551K(174784K), 0.0086944 secs] 253180K->251058K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0087373 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.476-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.476-0800: [Tenured: 174739K->174739K(174784K), 0.0069792 secs] 253210K->251905K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0071129 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.484-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.484-0800: [Tenured: 174739K->174750K(174784K), 0.0332736 secs] 253248K->251339K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0333169 secs] [Times: user=0.04 sys=0.00, real=0.03 secs] 2020-10-28T17:23:26.517-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.517-0800: [Tenured: 174750K->174750K(174784K), 0.0018706 secs] 253011K->251339K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0019012 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.520-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.520-0800: [Tenured: 174750K->174750K(174784K), 0.0034016 secs] 253189K->252164K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0034382 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:23:26.524-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.524-0800: [Tenured: 174750K->174750K(174784K), 0.0113330 secs] 253384K->251859K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0113780 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:23:26.536-0800: [Full GC (Allocation Failure) 2020-10-28T17:23:26.536-0800: [Tenured: 174750K->174716K(174784K), 0.0110047 secs] 252841K->251625K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0110484 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 执行结束! 共生成对象次数:4334 Heap def new generation total 78656K, used 77967K [0x00000007b0000000, 0x00000007b5550000, 0x00000007b5550000) eden space 69952K, 100% used [0x00000007b0000000, 0x00000007b4450000, 0x00000007b4450000) from space 8704K, 92% used [0x00000007b4cd0000, 0x00000007b54a3e80, 0x00000007b5550000) to space 8704K, 0% used [0x00000007b4450000, 0x00000007b4450000, 0x00000007b4cd0000) tenured generation total 174784K, used 174716K [0x00000007b5550000, 0x00000007c0000000, 0x00000007c0000000) the space 174784K, 99% used [0x00000007b5550000, 0x00000007bffef0e8, 0x00000007bffef200, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 512M堆内存 串行GC日志: ``` Learning_notes (main) ✗ java -XX:+UseSerialGC -Xms512m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:18:41.322-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.322-0800: [DefNew: 139776K->17472K(157248K), 0.0422957 secs] 139776K->43897K(506816K), 0.0423483 secs] [Times: user=0.02 sys=0.02, real=0.04 secs] 2020-10-28T17:18:41.399-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.399-0800: [DefNew: 156517K->17471K(157248K), 0.0429541 secs] 182943K->90471K(506816K), 0.0429893 secs] [Times: user=0.02 sys=0.02, real=0.05 secs] 2020-10-28T17:18:41.462-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.462-0800: [DefNew: 157247K->17471K(157248K), 0.0373394 secs] 230247K->140384K(506816K), 0.0373790 secs] [Times: user=0.02 sys=0.02, real=0.04 secs] 2020-10-28T17:18:41.522-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.522-0800: [DefNew: 157247K->17471K(157248K), 0.0312535 secs] 280160K->183647K(506816K), 0.0312891 secs] [Times: user=0.02 sys=0.01, real=0.03 secs] 2020-10-28T17:18:41.576-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.576-0800: [DefNew: 157247K->17470K(157248K), 0.0405926 secs] 323423K->231345K(506816K), 0.0406287 secs] [Times: user=0.02 sys=0.02, real=0.04 secs] 2020-10-28T17:18:41.640-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.640-0800: [DefNew: 157246K->17471K(157248K), 0.0458337 secs] 371121K->276867K(506816K), 0.0458776 secs] [Times: user=0.02 sys=0.01, real=0.04 secs] 2020-10-28T17:18:41.710-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.710-0800: [DefNew: 157247K->17470K(157248K), 0.0998372 secs] 416643K->325342K(506816K), 0.0998813 secs] [Times: user=0.02 sys=0.02, real=0.10 secs] 2020-10-28T17:18:41.834-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.834-0800: [DefNew: 157246K->157246K(157248K), 0.0000170 secs]2020-10-28T17:18:41.834-0800: [Tenured: 307872K->275697K(349568K), 0.0626824 secs] 465118K->275697K(506816K), [Metaspace: 2677K->2677K(1056768K)], 0.0627505 secs] [Times: user=0.06 sys=0.00, real=0.06 secs] 2020-10-28T17:18:41.921-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.921-0800: [DefNew: 139776K->17471K(157248K), 0.0080001 secs] 415473K->324926K(506816K), 0.0080394 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:18:41.954-0800: [GC (Allocation Failure) 2020-10-28T17:18:41.954-0800: [DefNew: 157247K->157247K(157248K), 0.0000171 secs]2020-10-28T17:18:41.954-0800: [Tenured: 307454K->309447K(349568K), 0.0425341 secs] 464702K->309447K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0426032 secs] [Times: user=0.04 sys=0.00, real=0.04 secs] 2020-10-28T17:18:42.017-0800: [GC (Allocation Failure) 2020-10-28T17:18:42.017-0800: [DefNew: 139776K->139776K(157248K), 0.0000167 secs]2020-10-28T17:18:42.017-0800: [Tenured: 309447K->316408K(349568K), 0.0435089 secs] 449223K->316408K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0435750 secs] [Times: user=0.04 sys=0.01, real=0.05 secs] 2020-10-28T17:18:42.081-0800: [GC (Allocation Failure) 2020-10-28T17:18:42.081-0800: [DefNew: 139776K->139776K(157248K), 0.0000211 secs]2020-10-28T17:18:42.081-0800: [Tenured: 316408K->313655K(349568K), 0.0467549 secs] 456184K->313655K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0468273 secs] [Times: user=0.05 sys=0.00, real=0.04 secs] 2020-10-28T17:18:42.147-0800: [GC (Allocation Failure) 2020-10-28T17:18:42.147-0800: [DefNew: 139776K->139776K(157248K), 0.0000262 secs]2020-10-28T17:18:42.147-0800: [Tenured: 313655K->343179K(349568K), 0.0445420 secs] 453431K->343179K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0446227 secs] [Times: user=0.03 sys=0.00, real=0.05 secs] 2020-10-28T17:18:42.212-0800: [GC (Allocation Failure) 2020-10-28T17:18:42.212-0800: [DefNew: 139776K->139776K(157248K), 0.0000257 secs]2020-10-28T17:18:42.212-0800: [Tenured: 343179K->347831K(349568K), 0.0434947 secs] 482955K->347831K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0435918 secs] [Times: user=0.04 sys=0.01, real=0.04 secs] 执行结束! 共生成对象次数:7336 Heap def new generation total 157248K, used 6214K [0x00000007a0000000, 0x00000007aaaa0000, 0x00000007aaaa0000) eden space 139776K, 4% used [0x00000007a0000000, 0x00000007a06119a0, 0x00000007a8880000) from space 17472K, 0% used [0x00000007a8880000, 0x00000007a8880000, 0x00000007a9990000) to space 17472K, 0% used [0x00000007a9990000, 0x00000007a9990000, 0x00000007aaaa0000) tenured generation total 349568K, used 347831K [0x00000007aaaa0000, 0x00000007c0000000, 0x00000007c0000000) the space 349568K, 99% used [0x00000007aaaa0000, 0x00000007bfe4de98, 0x00000007bfe4e000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 1G堆内存 串行GC日志: ``` Learning_notes (main) ✗ java -XX:+UseSerialGC -Xms1g -Xmx1g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:25:19.595-0800: [GC (Allocation Failure) 2020-10-28T17:25:19.595-0800: [DefNew: 279616K->34943K(314560K), 0.0517447 secs] 279616K->88102K(1013632K), 0.0517847 secs] [Times: user=0.03 sys=0.02, real=0.05 secs] 2020-10-28T17:25:19.700-0800: [GC (Allocation Failure) 2020-10-28T17:25:19.700-0800: [DefNew: 314559K->34943K(314560K), 0.0656548 secs] 367718K->155962K(1013632K), 0.0656895 secs] [Times: user=0.04 sys=0.03, real=0.06 secs] 2020-10-28T17:25:19.806-0800: [GC (Allocation Failure) 2020-10-28T17:25:19.806-0800: [DefNew: 314559K->34943K(314560K), 0.0543186 secs] 435578K->231219K(1013632K), 0.0543569 secs] [Times: user=0.03 sys=0.02, real=0.06 secs] 2020-10-28T17:25:19.897-0800: [GC (Allocation Failure) 2020-10-28T17:25:19.897-0800: [DefNew: 314559K->34943K(314560K), 0.0563115 secs] 510835K->311554K(1013632K), 0.0563485 secs] [Times: user=0.04 sys=0.02, real=0.06 secs] 2020-10-28T17:25:19.992-0800: [GC (Allocation Failure) 2020-10-28T17:25:19.992-0800: [DefNew: 314559K->34943K(314560K), 0.0555159 secs] 591170K->390769K(1013632K), 0.0555535 secs] [Times: user=0.03 sys=0.03, real=0.05 secs] 2020-10-28T17:25:20.091-0800: [GC (Allocation Failure) 2020-10-28T17:25:20.091-0800: [DefNew: 314559K->34941K(314560K), 0.0488204 secs] 670385K->459125K(1013632K), 0.0488580 secs] [Times: user=0.03 sys=0.02, real=0.04 secs] 2020-10-28T17:25:20.180-0800: [GC (Allocation Failure) 2020-10-28T17:25:20.180-0800: [DefNew: 314557K->34943K(314560K), 0.0628975 secs] 738741K->543647K(1013632K), 0.0629393 secs] [Times: user=0.03 sys=0.02, real=0.06 secs] 2020-10-28T17:25:20.283-0800: [GC (Allocation Failure) 2020-10-28T17:25:20.283-0800: [DefNew: 314559K->34943K(314560K), 0.0878184 secs] 823263K->620581K(1013632K), 0.0878558 secs] [Times: user=0.03 sys=0.03, real=0.09 secs] 2020-10-28T17:25:20.413-0800: [GC (Allocation Failure) 2020-10-28T17:25:20.413-0800: [DefNew: 314559K->34942K(314560K), 0.0728601 secs] 900197K->702923K(1013632K), 0.0729030 secs] [Times: user=0.04 sys=0.03, real=0.07 secs] 执行结束! 共生成对象次数:9403 Heap def new generation total 314560K, used 46381K [0x0000000780000000, 0x0000000795550000, 0x0000000795550000) eden space 279616K, 4% used [0x0000000780000000, 0x0000000780b2be10, 0x0000000791110000) from space 34944K, 99% used [0x0000000793330000, 0x000000079554f9a8, 0x0000000795550000) to space 34944K, 0% used [0x0000000791110000, 0x0000000791110000, 0x0000000793330000) tenured generation total 699072K, used 667981K [0x0000000795550000, 0x00000007c0000000, 0x00000007c0000000) the space 699072K, 95% used [0x0000000795550000, 0x00000007be1a3438, 0x00000007be1a3600, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 2G堆内存 串行GC日志: ``` java -XX:+UseSerialGC -Xms2g -Xmx2g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:26:04.434-0800: [GC (Allocation Failure) 2020-10-28T17:26:04.434-0800: [DefNew: 559232K->69888K(629120K), 0.0917799 secs] 559232K->159859K(2027264K), 0.0918248 secs] [Times: user=0.05 sys=0.04, real=0.09 secs] 2020-10-28T17:26:04.606-0800: [GC (Allocation Failure) 2020-10-28T17:26:04.606-0800: [DefNew: 629120K->69887K(629120K), 0.1087106 secs] 719091K->283430K(2027264K), 0.1087462 secs] [Times: user=0.06 sys=0.05, real=0.11 secs] 2020-10-28T17:26:04.792-0800: [GC (Allocation Failure) 2020-10-28T17:26:04.792-0800: [DefNew: 629119K->69887K(629120K), 0.0792271 secs] 842662K->404714K(2027264K), 0.0792611 secs] [Times: user=0.05 sys=0.03, real=0.08 secs] 2020-10-28T17:26:04.937-0800: [GC (Allocation Failure) 2020-10-28T17:26:04.937-0800: [DefNew: 629119K->69887K(629120K), 0.0780086 secs] 963946K->525843K(2027264K), 0.0780429 secs] [Times: user=0.05 sys=0.03, real=0.08 secs] 2020-10-28T17:26:05.086-0800: [GC (Allocation Failure) 2020-10-28T17:26:05.086-0800: [DefNew: 629119K->69887K(629120K), 0.0800751 secs] 1085075K->645858K(2027264K), 0.0801086 secs] [Times: user=0.05 sys=0.03, real=0.08 secs] 执行结束! 共生成对象次数:10520 Heap def new generation total 629120K, used 92373K [0x0000000740000000, 0x000000076aaa0000, 0x000000076aaa0000) eden space 559232K, 4% used [0x0000000740000000, 0x00000007415f54e8, 0x0000000762220000) from space 69888K, 99% used [0x0000000766660000, 0x000000076aa9fff0, 0x000000076aaa0000) to space 69888K, 0% used [0x0000000762220000, 0x0000000762220000, 0x0000000766660000) tenured generation total 1398144K, used 575970K [0x000000076aaa0000, 0x00000007c0000000, 0x00000007c0000000) the space 1398144K, 41% used [0x000000076aaa0000, 0x000000078dd18858, 0x000000078dd18a00, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 4G堆内存 串行GC日志: ``` Learning_notes (main) ✗ java -XX:+UseSerialGC -Xms4g -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:26:59.644-0800: [GC (Allocation Failure) 2020-10-28T17:26:59.645-0800: [DefNew: 1118528K->139775K(1258304K), 0.1813294 secs] 1118528K->262480K(4054528K), 0.1813705 secs] [Times: user=0.10 sys=0.07, real=0.18 secs] 2020-10-28T17:27:00.014-0800: [GC (Allocation Failure) 2020-10-28T17:27:00.014-0800: [DefNew: 1258303K->139775K(1258304K), 0.2447145 secs] 1381008K->417255K(4054528K), 0.2447534 secs] [Times: user=0.10 sys=0.09, real=0.24 secs] 执行结束! 共生成对象次数:8428 Heap def new generation total 1258304K, used 184670K [0x00000006c0000000, 0x0000000715550000, 0x0000000715550000) eden space 1118528K, 4% used [0x00000006c0000000, 0x00000006c2bd7a38, 0x0000000704450000) from space 139776K, 99% used [0x0000000704450000, 0x000000070cccfff0, 0x000000070ccd0000) to space 139776K, 0% used [0x000000070ccd0000, 0x000000070ccd0000, 0x0000000715550000) tenured generation total 2796224K, used 277479K [0x0000000715550000, 0x00000007c0000000, 0x00000007c0000000) the space 2796224K, 9% used [0x0000000715550000, 0x0000000726449f70, 0x000000072644a000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ###8G堆内存 串行GC日志: ``` Learning_notes (main) ✗ java -XX:+UseSerialGC -Xms8g -Xmx8g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 执行结束! 共生成对象次数:6357 Heap def new generation total 2516544K, used 1799273K [0x00000005c0000000, 0x000000066aaa0000, 0x000000066aaa0000) eden space 2236928K, 80% used [0x00000005c0000000, 0x000000062dd1a580, 0x0000000648880000) from space 279616K, 0% used [0x0000000648880000, 0x0000000648880000, 0x0000000659990000) to space 279616K, 0% used [0x0000000659990000, 0x0000000659990000, 0x000000066aaa0000) tenured generation total 5592448K, used 0K [0x000000066aaa0000, 0x00000007c0000000, 0x00000007c0000000) the space 5592448K, 0% used [0x000000066aaa0000, 0x000000066aaa0000, 0x000000066aaa0200, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ## 并行GC日志 ### 256M内存 并行GC日志 ``` Learning_notes (main) ✗ java -XX:+UseParallelGC -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:30:03.057-0800: [GC (Allocation Failure) [PSYoungGen: 65414K->10748K(76288K)] 65414K->25537K(251392K), 0.0100472 secs] [Times: user=0.02 sys=0.04, real=0.01 secs] 2020-10-28T17:30:03.082-0800: [GC (Allocation Failure) [PSYoungGen: 75583K->10751K(76288K)] 90372K->43297K(251392K), 0.0117256 secs] [Times: user=0.02 sys=0.05, real=0.01 secs] 2020-10-28T17:30:03.108-0800: [GC (Allocation Failure) [PSYoungGen: 76287K->10750K(76288K)] 108833K->61618K(251392K), 0.0092458 secs] [Times: user=0.02 sys=0.03, real=0.01 secs] 2020-10-28T17:30:03.130-0800: [GC (Allocation Failure) [PSYoungGen: 76206K->10741K(76288K)] 127075K->84681K(251392K), 0.0119042 secs] [Times: user=0.03 sys=0.05, real=0.01 secs] 2020-10-28T17:30:03.156-0800: [GC (Allocation Failure) [PSYoungGen: 76277K->10750K(76288K)] 150217K->106783K(251392K), 0.0109708 secs] [Times: user=0.02 sys=0.04, real=0.01 secs] 2020-10-28T17:30:03.177-0800: [GC (Allocation Failure) [PSYoungGen: 76076K->10746K(40448K)] 172109K->129982K(215552K), 0.0142001 secs] [Times: user=0.02 sys=0.04, real=0.02 secs] 2020-10-28T17:30:03.197-0800: [GC (Allocation Failure) [PSYoungGen: 40391K->14504K(58368K)] 159627K->136922K(233472K), 0.0034318 secs] [Times: user=0.02 sys=0.01, real=0.01 secs] 2020-10-28T17:30:03.205-0800: [GC (Allocation Failure) [PSYoungGen: 44200K->20415K(58368K)] 166618K->145766K(233472K), 0.0039650 secs] [Times: user=0.03 sys=0.00, real=0.00 secs] 2020-10-28T17:30:03.214-0800: [GC (Allocation Failure) [PSYoungGen: 50111K->28361K(58368K)] 175462K->157431K(233472K), 0.0049450 secs] [Times: user=0.03 sys=0.01, real=0.00 secs] 2020-10-28T17:30:03.225-0800: [GC (Allocation Failure) [PSYoungGen: 57639K->23063K(58368K)] 186709K->167969K(233472K), 0.0084908 secs] [Times: user=0.02 sys=0.03, real=0.01 secs] 2020-10-28T17:30:03.234-0800: [Full GC (Ergonomics) [PSYoungGen: 23063K->0K(58368K)] [ParOldGen: 144905K->140127K(175104K)] 167969K->140127K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0204331 secs] [Times: user=0.12 sys=0.01, real=0.02 secs] 2020-10-28T17:30:03.260-0800: [GC (Allocation Failure) [PSYoungGen: 29696K->9938K(58368K)] 169823K->150065K(233472K), 0.0023550 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:30:03.269-0800: [GC (Allocation Failure) [PSYoungGen: 38963K->11626K(58368K)] 179090K->161247K(233472K), 0.0043978 secs] [Times: user=0.02 sys=0.01, real=0.01 secs] 2020-10-28T17:30:03.274-0800: [Full GC (Ergonomics) [PSYoungGen: 11626K->0K(58368K)] [ParOldGen: 149621K->153345K(175104K)] 161247K->153345K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0197275 secs] [Times: user=0.11 sys=0.01, real=0.02 secs] 2020-10-28T17:30:03.301-0800: [Full GC (Ergonomics) [PSYoungGen: 29696K->0K(58368K)] [ParOldGen: 153345K->158572K(175104K)] 183041K->158572K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0217337 secs] [Times: user=0.10 sys=0.01, real=0.02 secs] 2020-10-28T17:30:03.329-0800: [Full GC (Ergonomics) [PSYoungGen: 29661K->0K(58368K)] [ParOldGen: 158572K->162250K(175104K)] 188233K->162250K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0230794 secs] [Times: user=0.10 sys=0.01, real=0.03 secs] 2020-10-28T17:30:03.359-0800: [Full GC (Ergonomics) [PSYoungGen: 29696K->0K(58368K)] [ParOldGen: 162250K->173263K(175104K)] 191946K->173263K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0242874 secs] [Times: user=0.12 sys=0.02, real=0.03 secs] 2020-10-28T17:30:03.389-0800: [Full GC (Ergonomics) [PSYoungGen: 29256K->3761K(58368K)] [ParOldGen: 173263K->174686K(175104K)] 202519K->178447K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0250308 secs] [Times: user=0.13 sys=0.00, real=0.03 secs] 2020-10-28T17:30:03.420-0800: [Full GC (Ergonomics) [PSYoungGen: 29408K->7140K(58368K)] [ParOldGen: 174686K->175001K(175104K)] 204094K->182142K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0234358 secs] [Times: user=0.14 sys=0.01, real=0.02 secs] 2020-10-28T17:30:03.450-0800: [Full GC (Ergonomics) [PSYoungGen: 29696K->10727K(58368K)] [ParOldGen: 175001K->174522K(175104K)] 204697K->185249K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0249157 secs] [Times: user=0.11 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.480-0800: [Full GC (Ergonomics) [PSYoungGen: 29563K->15015K(58368K)] [ParOldGen: 174522K->174350K(175104K)] 204085K->189366K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0261625 secs] [Times: user=0.13 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.509-0800: [Full GC (Ergonomics) [PSYoungGen: 29667K->15890K(58368K)] [ParOldGen: 174350K->174545K(175104K)] 204017K->190436K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0252998 secs] [Times: user=0.15 sys=0.00, real=0.03 secs] 2020-10-28T17:30:03.537-0800: [Full GC (Ergonomics) [PSYoungGen: 29696K->18025K(58368K)] [ParOldGen: 174545K->174810K(175104K)] 204241K->192835K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0250460 secs] [Times: user=0.17 sys=0.00, real=0.03 secs] 2020-10-28T17:30:03.564-0800: [Full GC (Ergonomics) [PSYoungGen: 29637K->19580K(58368K)] [ParOldGen: 174810K->174892K(175104K)] 204447K->194472K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0217244 secs] [Times: user=0.14 sys=0.01, real=0.02 secs] 2020-10-28T17:30:03.588-0800: [Full GC (Ergonomics) [PSYoungGen: 29619K->23802K(58368K)] [ParOldGen: 174892K->174888K(175104K)] 204512K->198690K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0242850 secs] [Times: user=0.16 sys=0.00, real=0.03 secs] 2020-10-28T17:30:03.613-0800: [Full GC (Ergonomics) [PSYoungGen: 29654K->23868K(58368K)] [ParOldGen: 174888K->175000K(175104K)] 204542K->198868K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0202639 secs] [Times: user=0.12 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.636-0800: [Full GC (Ergonomics) [PSYoungGen: 29635K->24344K(58368K)] [ParOldGen: 175000K->174631K(175104K)] 204635K->198976K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0206868 secs] [Times: user=0.12 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.657-0800: [Full GC (Ergonomics) [PSYoungGen: 29470K->25422K(58368K)] [ParOldGen: 174631K->174532K(175104K)] 204101K->199955K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0123513 secs] [Times: user=0.07 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.670-0800: [Full GC (Ergonomics) [PSYoungGen: 29531K->26139K(58368K)] [ParOldGen: 174532K->174956K(175104K)] 204064K->201096K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0257267 secs] [Times: user=0.16 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.697-0800: [Full GC (Ergonomics) [PSYoungGen: 29693K->27070K(58368K)] [ParOldGen: 174956K->174789K(175104K)] 204650K->201860K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0243107 secs] [Times: user=0.16 sys=0.01, real=0.03 secs] 2020-10-28T17:30:03.722-0800: [Full GC (Ergonomics) [PSYoungGen: 29658K->27845K(58368K)] [ParOldGen: 174789K->174379K(175104K)] 204448K->202225K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0209275 secs] [Times: user=0.14 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.743-0800: [Full GC (Ergonomics) [PSYoungGen: 29500K->27410K(58368K)] [ParOldGen: 174379K->175058K(175104K)] 203879K->202468K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0195943 secs] [Times: user=0.12 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.763-0800: [Full GC (Ergonomics) [PSYoungGen: 29354K->28885K(58368K)] [ParOldGen: 175058K->174583K(175104K)] 204413K->203468K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0205829 secs] [Times: user=0.14 sys=0.00, real=0.02 secs] 2020-10-28T17:30:03.784-0800: [Full GC (Ergonomics) [PSYoungGen: 29604K->29604K(58368K)] [ParOldGen: 174583K->174583K(175104K)] 204188K->204188K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0036260 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:30:03.788-0800: [Full GC (Ergonomics) [PSYoungGen: 29604K->29604K(58368K)] [ParOldGen: 174707K->174583K(175104K)] 204312K->204188K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0026627 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:30:03.790-0800: [Full GC (Allocation Failure) [PSYoungGen: 29604K->29604K(58368K)] [ParOldGen: 174583K->174563K(175104K)] 204188K->204168K(233472K), [Metaspace: 2678K->2678K(1056768K)], 0.0152678 secs] [Times: user=0.10 sys=0.00, real=0.01 secs] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at GCLogAnalysis.generateGarbage(GCLogAnalysis.java:60) at GCLogAnalysis.main(GCLogAnalysis.java:31) Heap PSYoungGen total 58368K, used 29696K [0x00000007bab00000, 0x00000007c0000000, 0x00000007c0000000) eden space 29696K, 100% used [0x00000007bab00000,0x00000007bc800000,0x00000007bc800000) from space 28672K, 0% used [0x00000007be400000,0x00000007be400000,0x00000007c0000000) to space 28672K, 0% used [0x00000007bc800000,0x00000007bc800000,0x00000007be400000) ParOldGen total 175104K, used 174563K [0x00000007b0000000, 0x00000007bab00000, 0x00000007bab00000) object space 175104K, 99% used [0x00000007b0000000,0x00000007baa78f08,0x00000007bab00000) Metaspace used 2708K, capacity 4486K, committed 4864K, reserved 1056768K class space used 297K, capacity 386K, committed 512K, reserved 1048576K ``` ### 512M内存 并行GC日志 ``` Learning_notes (main) ✗ java -XX:+UseParallelGC -Xms512m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:30:49.257-0800: [GC (Allocation Failure) [PSYoungGen: 131584K->21493K(153088K)] 131584K->44201K(502784K), 0.0172941 secs] [Times: user=0.02 sys=0.09, real=0.02 secs] 2020-10-28T17:30:49.304-0800: [GC (Allocation Failure) [PSYoungGen: 153077K->21489K(153088K)] 175785K->86159K(502784K), 0.0249816 secs] [Times: user=0.04 sys=0.11, real=0.02 secs] 2020-10-28T17:30:49.347-0800: [GC (Allocation Failure) [PSYoungGen: 153073K->21499K(153088K)] 217743K->128830K(502784K), 0.0230683 secs] [Times: user=0.04 sys=0.10, real=0.03 secs] 2020-10-28T17:30:49.389-0800: [GC (Allocation Failure) [PSYoungGen: 153077K->21498K(153088K)] 260408K->173282K(502784K), 0.0233284 secs] [Times: user=0.04 sys=0.10, real=0.03 secs] 2020-10-28T17:30:49.432-0800: [GC (Allocation Failure) [PSYoungGen: 153082K->21491K(153088K)] 304866K->216518K(502784K), 0.0218531 secs] [Times: user=0.03 sys=0.09, real=0.02 secs] 2020-10-28T17:30:49.473-0800: [GC (Allocation Failure) [PSYoungGen: 153075K->21498K(80384K)] 348102K->255883K(430080K), 0.0211237 secs] [Times: user=0.04 sys=0.09, real=0.02 secs] 2020-10-28T17:30:49.503-0800: [GC (Allocation Failure) [PSYoungGen: 79796K->38630K(116736K)] 314181K->276178K(466432K), 0.0050862 secs] [Times: user=0.03 sys=0.00, real=0.00 secs] 2020-10-28T17:30:49.519-0800: [GC (Allocation Failure) [PSYoungGen: 97510K->50091K(116736K)] 335058K->292848K(466432K), 0.0082298 secs] [Times: user=0.04 sys=0.01, real=0.01 secs] 2020-10-28T17:30:49.537-0800: [GC (Allocation Failure) [PSYoungGen: 108967K->57721K(116736K)] 351725K->309884K(466432K), 0.0116315 secs] [Times: user=0.05 sys=0.02, real=0.01 secs] 2020-10-28T17:30:49.560-0800: [GC (Allocation Failure) [PSYoungGen: 116564K->38429K(116736K)] 368727K->323327K(466432K), 0.0176745 secs] [Times: user=0.04 sys=0.07, real=0.01 secs] 2020-10-28T17:30:49.588-0800: [GC (Allocation Failure) [PSYoungGen: 97309K->20887K(116736K)] 382207K->340070K(466432K), 0.0178082 secs] [Times: user=0.03 sys=0.07, real=0.02 secs] 2020-10-28T17:30:49.606-0800: [Full GC (Ergonomics) [PSYoungGen: 20887K->0K(116736K)] [ParOldGen: 319183K->238238K(349696K)] 340070K->238238K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0366207 secs] [Times: user=0.19 sys=0.01, real=0.04 secs] 2020-10-28T17:30:49.655-0800: [GC (Allocation Failure) [PSYoungGen: 58651K->14484K(116736K)] 296890K->252723K(466432K), 0.0021529 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:30:49.668-0800: [GC (Allocation Failure) [PSYoungGen: 73364K->24025K(116736K)] 311603K->275650K(466432K), 0.0053394 secs] [Times: user=0.04 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.684-0800: [GC (Allocation Failure) [PSYoungGen: 82483K->19782K(116736K)] 334107K->293826K(466432K), 0.0058295 secs] [Times: user=0.04 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.702-0800: [GC (Allocation Failure) [PSYoungGen: 78662K->18220K(116736K)] 352706K->311229K(466432K), 0.0057487 secs] [Times: user=0.03 sys=0.00, real=0.00 secs] 2020-10-28T17:30:49.719-0800: [GC (Allocation Failure) [PSYoungGen: 77100K->17599K(116736K)] 370109K->328171K(466432K), 0.0056839 secs] [Times: user=0.03 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.724-0800: [Full GC (Ergonomics) [PSYoungGen: 17599K->0K(116736K)] [ParOldGen: 310572K->267598K(349696K)] 328171K->267598K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0367548 secs] [Times: user=0.19 sys=0.01, real=0.04 secs] 2020-10-28T17:30:49.774-0800: [GC (Allocation Failure) [PSYoungGen: 58609K->20160K(116736K)] 326207K->287758K(466432K), 0.0046939 secs] [Times: user=0.02 sys=0.00, real=0.00 secs] 2020-10-28T17:30:49.789-0800: [GC (Allocation Failure) [PSYoungGen: 79028K->18560K(116736K)] 346626K->305297K(466432K), 0.0056834 secs] [Times: user=0.03 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.805-0800: [GC (Allocation Failure) [PSYoungGen: 77440K->25791K(116736K)] 364177K->328900K(466432K), 0.0064709 secs] [Times: user=0.04 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.821-0800: [GC (Allocation Failure) [PSYoungGen: 84134K->25420K(116736K)] 387243K->353075K(466432K), 0.0086230 secs] [Times: user=0.02 sys=0.02, real=0.01 secs] 2020-10-28T17:30:49.830-0800: [Full GC (Ergonomics) [PSYoungGen: 25420K->0K(116736K)] [ParOldGen: 327654K->300444K(349696K)] 353075K->300444K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0386200 secs] [Times: user=0.21 sys=0.00, real=0.03 secs] 2020-10-28T17:30:49.884-0800: [GC (Allocation Failure) [PSYoungGen: 58880K->20822K(116736K)] 359324K->321267K(466432K), 0.0039121 secs] [Times: user=0.02 sys=0.00, real=0.00 secs] 2020-10-28T17:30:49.898-0800: [GC (Allocation Failure) [PSYoungGen: 79702K->18555K(116736K)] 380147K->338305K(466432K), 0.0055579 secs] [Times: user=0.04 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.904-0800: [Full GC (Ergonomics) [PSYoungGen: 18555K->0K(116736K)] [ParOldGen: 319750K->310166K(349696K)] 338305K->310166K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0389125 secs] [Times: user=0.21 sys=0.01, real=0.04 secs] 2020-10-28T17:30:49.957-0800: [GC (Allocation Failure) [PSYoungGen: 58841K->22552K(116736K)] 369008K->332719K(466432K), 0.0050450 secs] [Times: user=0.03 sys=0.00, real=0.01 secs] 2020-10-28T17:30:49.973-0800: [GC (Allocation Failure) [PSYoungGen: 81284K->21563K(116736K)] 391450K->353498K(466432K), 0.0078708 secs] [Times: user=0.03 sys=0.01, real=0.01 secs] 2020-10-28T17:30:49.981-0800: [Full GC (Ergonomics) [PSYoungGen: 21563K->0K(116736K)] [ParOldGen: 331934K->321001K(349696K)] 353498K->321001K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0393775 secs] [Times: user=0.24 sys=0.00, real=0.04 secs] 2020-10-28T17:30:50.035-0800: [Full GC (Ergonomics) [PSYoungGen: 58436K->0K(116736K)] [ParOldGen: 321001K->325098K(349696K)] 379437K->325098K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0413652 secs] [Times: user=0.24 sys=0.01, real=0.04 secs] 2020-10-28T17:30:50.089-0800: [Full GC (Ergonomics) [PSYoungGen: 58880K->0K(116736K)] [ParOldGen: 325098K->330497K(349696K)] 383978K->330497K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0402942 secs] [Times: user=0.24 sys=0.00, real=0.04 secs] 2020-10-28T17:30:50.141-0800: [Full GC (Ergonomics) [PSYoungGen: 58880K->0K(116736K)] [ParOldGen: 330497K->334357K(349696K)] 389377K->334357K(466432K), [Metaspace: 2678K->2678K(1056768K)], 0.0469755 secs] [Times: user=0.23 sys=0.01, real=0.04 secs] 执行结束! 共生成对象次数:7787 Heap PSYoungGen total 116736K, used 2631K [0x00000007b5580000, 0x00000007c0000000, 0x00000007c0000000) eden space 58880K, 4% used [0x00000007b5580000,0x00000007b5811db8,0x00000007b8f00000) from space 57856K, 0% used [0x00000007bc780000,0x00000007bc780000,0x00000007c0000000) to space 57856K, 0% used [0x00000007b8f00000,0x00000007b8f00000,0x00000007bc780000) ParOldGen total 349696K, used 334357K [0x00000007a0000000, 0x00000007b5580000, 0x00000007b5580000) object space 349696K, 95% used [0x00000007a0000000,0x00000007b46856d8,0x00000007b5580000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 1G内存 并行GC日志 ``` java -XX:+UseParallelGC -Xms1g -Xmx1g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:31:19.395-0800: [GC (Allocation Failure) [PSYoungGen: 262144K->43502K(305664K)] 262144K->75639K(1005056K), 0.0323196 secs] [Times: user=0.04 sys=0.14, real=0.03 secs] 2020-10-28T17:31:19.465-0800: [GC (Allocation Failure) [PSYoungGen: 305646K->43519K(305664K)] 337783K->149795K(1005056K), 0.0454068 secs] [Times: user=0.06 sys=0.17, real=0.05 secs] 2020-10-28T17:31:19.549-0800: [GC (Allocation Failure) [PSYoungGen: 305663K->43518K(305664K)] 411939K->216217K(1005056K), 0.0350760 secs] [Times: user=0.07 sys=0.09, real=0.04 secs] 2020-10-28T17:31:19.620-0800: [GC (Allocation Failure) [PSYoungGen: 305662K->43511K(305664K)] 478361K->289311K(1005056K), 0.0391987 secs] [Times: user=0.07 sys=0.15, real=0.03 secs] 2020-10-28T17:31:19.703-0800: [GC (Allocation Failure) [PSYoungGen: 305655K->43507K(305664K)] 551455K->360777K(1005056K), 0.0364331 secs] [Times: user=0.06 sys=0.15, real=0.04 secs] 2020-10-28T17:31:19.779-0800: [GC (Allocation Failure) [PSYoungGen: 305651K->43511K(160256K)] 622921K->441436K(859648K), 0.0396001 secs] [Times: user=0.06 sys=0.17, real=0.04 secs] 2020-10-28T17:31:19.835-0800: [GC (Allocation Failure) [PSYoungGen: 160247K->77226K(232960K)] 558172K->478051K(932352K), 0.0109938 secs] [Times: user=0.06 sys=0.01, real=0.01 secs] 2020-10-28T17:31:19.866-0800: [GC (Allocation Failure) [PSYoungGen: 193652K->99827K(232960K)] 594478K->509750K(932352K), 0.0155469 secs] [Times: user=0.07 sys=0.02, real=0.02 secs] 2020-10-28T17:31:19.901-0800: [GC (Allocation Failure) [PSYoungGen: 216452K->112438K(232960K)] 626375K->542651K(932352K), 0.0208013 secs] [Times: user=0.07 sys=0.03, real=0.02 secs] 2020-10-28T17:31:19.940-0800: [GC (Allocation Failure) [PSYoungGen: 229174K->77506K(232960K)] 659387K->567901K(932352K), 0.0333276 secs] [Times: user=0.06 sys=0.14, real=0.03 secs] 2020-10-28T17:31:19.993-0800: [GC (Allocation Failure) [PSYoungGen: 194242K->41360K(232960K)] 684637K->598685K(932352K), 0.0313548 secs] [Times: user=0.04 sys=0.14, real=0.03 secs] 2020-10-28T17:31:20.043-0800: [GC (Allocation Failure) [PSYoungGen: 158096K->36679K(232960K)] 715421K->630158K(932352K), 0.0177119 secs] [Times: user=0.03 sys=0.07, real=0.02 secs] 2020-10-28T17:31:20.082-0800: [GC (Allocation Failure) [PSYoungGen: 153415K->31290K(232960K)] 746894K->658640K(932352K), 0.0158651 secs] [Times: user=0.04 sys=0.07, real=0.01 secs] 2020-10-28T17:31:20.098-0800: [Full GC (Ergonomics) [PSYoungGen: 31290K->0K(232960K)] [ParOldGen: 627350K->330974K(699392K)] 658640K->330974K(932352K), [Metaspace: 2678K->2678K(1056768K)], 0.0542396 secs] [Times: user=0.26 sys=0.01, real=0.06 secs] 2020-10-28T17:31:20.175-0800: [GC (Allocation Failure) [PSYoungGen: 116736K->36282K(232960K)] 447710K->367257K(932352K), 0.0122410 secs] [Times: user=0.02 sys=0.01, real=0.01 secs] 2020-10-28T17:31:20.214-0800: [GC (Allocation Failure) [PSYoungGen: 153018K->34312K(232960K)] 483993K->397488K(932352K), 0.0108175 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] 执行结束! 共生成对象次数:10106 Heap PSYoungGen total 232960K, used 81814K [0x00000007aab00000, 0x00000007c0000000, 0x00000007c0000000) eden space 116736K, 40% used [0x00000007aab00000,0x00000007ad9639b0,0x00000007b1d00000) from space 116224K, 29% used [0x00000007b1d00000,0x00000007b3e82160,0x00000007b8e80000) to space 116224K, 0% used [0x00000007b8e80000,0x00000007b8e80000,0x00000007c0000000) ParOldGen total 699392K, used 363176K [0x0000000780000000, 0x00000007aab00000, 0x00000007aab00000) object space 699392K, 51% used [0x0000000780000000,0x00000007962aa048,0x00000007aab00000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 2G内存 并行GC日志 ``` java -XX:+UseParallelGC -Xms2g -Xmx2g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:31:42.073-0800: [GC (Allocation Failure) [PSYoungGen: 524800K->87030K(611840K)] 524800K->143377K(2010112K), 0.0580173 secs] [Times: user=0.07 sys=0.29, real=0.06 secs] 2020-10-28T17:31:42.212-0800: [GC (Allocation Failure) [PSYoungGen: 611830K->87036K(611840K)] 668177K->254243K(2010112K), 0.0790885 secs] [Times: user=0.09 sys=0.39, real=0.08 secs] 2020-10-28T17:31:42.364-0800: [GC (Allocation Failure) [PSYoungGen: 611836K->87026K(611840K)] 779043K->371293K(2010112K), 0.0635106 secs] [Times: user=0.11 sys=0.25, real=0.06 secs] 2020-10-28T17:31:42.493-0800: [GC (Allocation Failure) [PSYoungGen: 611826K->87039K(611840K)] 896093K->477458K(2010112K), 0.0629194 secs] [Times: user=0.11 sys=0.26, real=0.06 secs] 2020-10-28T17:31:42.627-0800: [GC (Allocation Failure) [PSYoungGen: 611695K->87033K(611840K)] 1002114K->586009K(2010112K), 0.0627900 secs] [Times: user=0.11 sys=0.24, real=0.07 secs] 执行结束! 共生成对象次数:11867 Heap PSYoungGen total 611840K, used 611833K [0x0000000795580000, 0x00000007c0000000, 0x00000007c0000000) eden space 524800K, 100% used [0x0000000795580000,0x00000007b5600000,0x00000007b5600000) from space 87040K, 99% used [0x00000007b5600000,0x00000007baafe538,0x00000007bab00000) to space 87040K, 0% used [0x00000007bab00000,0x00000007bab00000,0x00000007c0000000) ParOldGen total 1398272K, used 498976K [0x0000000740000000, 0x0000000795580000, 0x0000000795580000) object space 1398272K, 35% used [0x0000000740000000,0x000000075e748218,0x0000000795580000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 4G内存 并行GC日志 ``` java -XX:+UseParallelGC -Xms4g -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:32:22.581-0800: [GC (Allocation Failure) [PSYoungGen: 1048576K->174580K(1223168K)] 1048576K->238872K(4019712K), 0.0996263 secs] [Times: user=0.10 sys=0.44, real=0.10 secs] 2020-10-28T17:32:22.837-0800: [GC (Allocation Failure) [PSYoungGen: 1223156K->174590K(1223168K)] 1287448K->372940K(4019712K), 0.1257143 secs] [Times: user=0.14 sys=0.60, real=0.13 secs] 执行结束! 共生成对象次数:8587 Heap PSYoungGen total 1223168K, used 407020K [0x000000076ab00000, 0x00000007c0000000, 0x00000007c0000000) eden space 1048576K, 22% used [0x000000076ab00000,0x0000000778dfbae8,0x00000007aab00000) from space 174592K, 99% used [0x00000007b5580000,0x00000007bffff828,0x00000007c0000000) to space 174592K, 0% used [0x00000007aab00000,0x00000007aab00000,0x00000007b5580000) ParOldGen total 2796544K, used 198350K [0x00000006c0000000, 0x000000076ab00000, 0x000000076ab00000) object space 2796544K, 7% used [0x00000006c0000000,0x00000006cc1b38a8,0x000000076ab00000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 8G内存 并行GC日志 ``` Learning_notes (main) ✗ java -XX:+UseParallelGC -Xms8g -Xmx8g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 执行结束! 共生成对象次数:6434 Heap PSYoungGen total 2446848K, used 1814029K [0x0000000715580000, 0x00000007c0000000, 0x00000007c0000000) eden space 2097664K, 86% used [0x0000000715580000,0x0000000784103408,0x0000000795600000) from space 349184K, 0% used [0x00000007aab00000,0x00000007aab00000,0x00000007c0000000) to space 349184K, 0% used [0x0000000795600000,0x0000000795600000,0x00000007aab00000) ParOldGen total 5592576K, used 0K [0x00000005c0000000, 0x0000000715580000, 0x0000000715580000) object space 5592576K, 0% used [0x00000005c0000000,0x00000005c0000000,0x0000000715580000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ## CMS GC日志 ### 256M堆内存 CMS GC日志 ``` Learning_notes (main) ✗ java -XX:+UseConcMarkSweepGC -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:33:44.934-0800: [GC (Allocation Failure) 2020-10-28T17:33:44.934-0800: [ParNew: 69952K->8699K(78656K), 0.0088419 secs] 69952K->20426K(253440K), 0.0089039 secs] [Times: user=0.02 sys=0.03, real=0.01 secs] 2020-10-28T17:33:44.961-0800: [GC (Allocation Failure) 2020-10-28T17:33:44.961-0800: [ParNew: 78412K->8693K(78656K), 0.0108120 secs] 90139K->39796K(253440K), 0.0108515 secs] [Times: user=0.03 sys=0.04, real=0.01 secs] 2020-10-28T17:33:44.986-0800: [GC (Allocation Failure) 2020-10-28T17:33:44.986-0800: [ParNew: 78645K->8704K(78656K), 0.0172434 secs] 109748K->63761K(253440K), 0.0172923 secs] [Times: user=0.09 sys=0.01, real=0.02 secs] 2020-10-28T17:33:45.018-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.018-0800: [ParNew: 78656K->8699K(78656K), 0.0144355 secs] 133713K->85818K(253440K), 0.0144731 secs] [Times: user=0.09 sys=0.01, real=0.02 secs] 2020-10-28T17:33:45.044-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.044-0800: [ParNew: 78651K->8700K(78656K), 0.0172643 secs] 155770K->112741K(253440K), 0.0173123 secs] [Times: user=0.12 sys=0.01, real=0.02 secs] 2020-10-28T17:33:45.061-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 104040K(174784K)] 112817K(253440K), 0.0001874 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.061-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.063-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.063-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.063-0800: [CMS-concurrent-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.063-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.071-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.071-0800: [ParNew: 78621K->8698K(78656K), 0.0170563 secs] 182662K->137990K(253440K), 0.0170948 secs] [Times: user=0.11 sys=0.01, real=0.01 secs] 2020-10-28T17:33:45.099-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.099-0800: [ParNew: 78313K->8702K(78656K), 0.0157949 secs] 207606K->161029K(253440K), 0.0158329 secs] [Times: user=0.10 sys=0.01, real=0.02 secs] 2020-10-28T17:33:45.126-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.126-0800: [ParNew: 78137K->78137K(78656K), 0.0000201 secs]2020-10-28T17:33:45.126-0800: [CMS2020-10-28T17:33:45.126-0800: [CMS-concurrent-abortable-preclean: 0.002/0.063 secs] [Times: user=0.24 sys=0.02, real=0.06 secs] (concurrent mode failure): 152326K->154594K(174784K), 0.0280426 secs] 230464K->154594K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0281172 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.166-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.166-0800: [ParNew: 69952K->8701K(78656K), 0.0096386 secs] 224546K->177188K(253440K), 0.0096775 secs] [Times: user=0.06 sys=0.01, real=0.01 secs] 2020-10-28T17:33:45.176-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 168486K(174784K)] 177900K(253440K), 0.0001883 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.176-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.177-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.177-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.177-0800: [CMS-concurrent-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.177-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.178-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.178-0800: [GC (CMS Final Remark) [YG occupancy: 17915 K (78656 K)]2020-10-28T17:33:45.178-0800: [Rescan (parallel) , 0.0002093 secs]2020-10-28T17:33:45.178-0800: [weak refs processing, 0.0000098 secs]2020-10-28T17:33:45.178-0800: [class unloading, 0.0001836 secs]2020-10-28T17:33:45.178-0800: [scrub symbol table, 0.0002854 secs]2020-10-28T17:33:45.178-0800: [scrub string table, 0.0001183 secs][1 CMS-remark: 168486K(174784K)] 186402K(253440K), 0.0008475 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.178-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.179-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.179-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.179-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.189-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.189-0800: [ParNew (promotion failed): 78095K->78096K(78656K), 0.0072044 secs]2020-10-28T17:33:45.196-0800: [CMS: 174309K->174551K(174784K), 0.0240507 secs] 234896K->180928K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0313149 secs] [Times: user=0.06 sys=0.00, real=0.04 secs] 2020-10-28T17:33:45.221-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174551K(174784K)] 181602K(253440K), 0.0001581 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.221-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.222-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.222-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.222-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.222-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.222-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.223-0800: [GC (CMS Final Remark) [YG occupancy: 17981 K (78656 K)]2020-10-28T17:33:45.223-0800: [Rescan (parallel) , 0.0002086 secs]2020-10-28T17:33:45.223-0800: [weak refs processing, 0.0000117 secs]2020-10-28T17:33:45.223-0800: [class unloading, 0.0001817 secs]2020-10-28T17:33:45.223-0800: [scrub symbol table, 0.0002889 secs]2020-10-28T17:33:45.223-0800: [scrub string table, 0.0001186 secs][1 CMS-remark: 174551K(174784K)] 192532K(253440K), 0.0008581 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.224-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.224-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.224-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.224-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.233-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.233-0800: [ParNew: 78607K->78607K(78656K), 0.0000193 secs]2020-10-28T17:33:45.233-0800: [CMS: 174551K->174699K(174784K), 0.0263119 secs] 253158K->190906K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0263813 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.260-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174699K(174784K)] 191542K(253440K), 0.0001780 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.260-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.261-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.261-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.262-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.262-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.262-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.262-0800: [GC (CMS Final Remark) [YG occupancy: 28326 K (78656 K)]2020-10-28T17:33:45.262-0800: [Rescan (parallel) , 0.0009024 secs]2020-10-28T17:33:45.263-0800: [weak refs processing, 0.0000153 secs]2020-10-28T17:33:45.263-0800: [class unloading, 0.0001910 secs]2020-10-28T17:33:45.263-0800: [scrub symbol table, 0.0002861 secs]2020-10-28T17:33:45.264-0800: [scrub string table, 0.0001184 secs][1 CMS-remark: 174699K(174784K)] 203025K(253440K), 0.0015649 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.264-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.264-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.264-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.264-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.271-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.271-0800: [ParNew: 78558K->78558K(78656K), 0.0000208 secs]2020-10-28T17:33:45.271-0800: [CMS: 174651K->174082K(174784K), 0.0266043 secs] 253209K->202294K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0266801 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 2020-10-28T17:33:45.298-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174082K(174784K)] 202725K(253440K), 0.0001760 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.298-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.299-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.299-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.300-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 2020-10-28T17:33:45.300-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.300-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.300-0800: [GC (CMS Final Remark) [YG occupancy: 39383 K (78656 K)]2020-10-28T17:33:45.300-0800: [Rescan (parallel) , 0.0006049 secs]2020-10-28T17:33:45.301-0800: [weak refs processing, 0.0000136 secs]2020-10-28T17:33:45.301-0800: [class unloading, 0.0001833 secs]2020-10-28T17:33:45.301-0800: [scrub symbol table, 0.0002827 secs]2020-10-28T17:33:45.301-0800: [scrub string table, 0.0001187 secs][1 CMS-remark: 174082K(174784K)] 213465K(253440K), 0.0012511 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.301-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.302-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.302-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.302-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.307-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.307-0800: [ParNew: 78655K->78655K(78656K), 0.0000198 secs]2020-10-28T17:33:45.307-0800: [CMS: 173886K->174600K(174784K), 0.0277043 secs] 252541K->214632K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0277738 secs] [Times: user=0.02 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.335-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174600K(174784K)] 214668K(253440K), 0.0001803 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.335-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.336-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.336-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.337-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.337-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.337-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.337-0800: [GC (CMS Final Remark) [YG occupancy: 51966 K (78656 K)]2020-10-28T17:33:45.337-0800: [Rescan (parallel) , 0.0010210 secs]2020-10-28T17:33:45.338-0800: [weak refs processing, 0.0000221 secs]2020-10-28T17:33:45.338-0800: [class unloading, 0.0002375 secs]2020-10-28T17:33:45.338-0800: [scrub symbol table, 0.0003349 secs]2020-10-28T17:33:45.339-0800: [scrub string table, 0.0001374 secs][1 CMS-remark: 174600K(174784K)] 226567K(253440K), 0.0018363 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.339-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.339-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.339-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.339-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.343-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.343-0800: [ParNew: 78475K->78475K(78656K), 0.0000194 secs]2020-10-28T17:33:45.343-0800: [CMS: 174600K->174478K(174784K), 0.0287244 secs] 253075K->222659K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0287973 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.372-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174478K(174784K)] 222908K(253440K), 0.0001814 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.372-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.373-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.373-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.374-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.374-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.374-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.374-0800: [GC (CMS Final Remark) [YG occupancy: 60767 K (78656 K)]2020-10-28T17:33:45.374-0800: [Rescan (parallel) , 0.0002255 secs]2020-10-28T17:33:45.374-0800: [weak refs processing, 0.0000100 secs]2020-10-28T17:33:45.374-0800: [class unloading, 0.0001858 secs]2020-10-28T17:33:45.375-0800: [scrub symbol table, 0.0002858 secs]2020-10-28T17:33:45.375-0800: [scrub string table, 0.0001186 secs][1 CMS-remark: 174478K(174784K)] 235245K(253440K), 0.0008711 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.375-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.375-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.375-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.375-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.378-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.378-0800: [ParNew: 78641K->78641K(78656K), 0.0000192 secs]2020-10-28T17:33:45.378-0800: [CMS: 174478K->174526K(174784K), 0.0282014 secs] 253119K->226947K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0282688 secs] [Times: user=0.02 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.406-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174526K(174784K)] 227019K(253440K), 0.0001887 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.407-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.407-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.01, real=0.00 secs] 2020-10-28T17:33:45.407-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.408-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.408-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.408-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.408-0800: [GC (CMS Final Remark) [YG occupancy: 64816 K (78656 K)]2020-10-28T17:33:45.408-0800: [Rescan (parallel) , 0.0002069 secs]2020-10-28T17:33:45.409-0800: [weak refs processing, 0.0000097 secs]2020-10-28T17:33:45.409-0800: [class unloading, 0.0001761 secs]2020-10-28T17:33:45.409-0800: [scrub symbol table, 0.0003004 secs]2020-10-28T17:33:45.409-0800: [scrub string table, 0.0001360 secs][1 CMS-remark: 174526K(174784K)] 239342K(253440K), 0.0008789 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.409-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.410-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2020-10-28T17:33:45.410-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.410-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.412-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.412-0800: [ParNew: 78464K->78464K(78656K), 0.0000302 secs]2020-10-28T17:33:45.412-0800: [CMS: 174526K->174700K(174784K), 0.0303129 secs] 252990K->232110K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0304547 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.443-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174700K(174784K)] 232398K(253440K), 0.0001999 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.443-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.444-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.444-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.445-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.445-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.445-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.445-0800: [GC (CMS Final Remark) [YG occupancy: 67254 K (78656 K)]2020-10-28T17:33:45.445-0800: [Rescan (parallel) , 0.0002315 secs]2020-10-28T17:33:45.445-0800: [weak refs processing, 0.0000121 secs]2020-10-28T17:33:45.445-0800: [class unloading, 0.0001807 secs]2020-10-28T17:33:45.445-0800: [scrub symbol table, 0.0002874 secs]2020-10-28T17:33:45.446-0800: [scrub string table, 0.0001192 secs][1 CMS-remark: 174700K(174784K)] 241955K(253440K), 0.0008760 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.446-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.446-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.446-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.446-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.448-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.448-0800: [ParNew: 78550K->78550K(78656K), 0.0000168 secs]2020-10-28T17:33:45.448-0800: [CMS: 174513K->174733K(174784K), 0.0274961 secs] 253063K->234208K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0275528 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.476-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174733K(174784K)] 234352K(253440K), 0.0003442 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.476-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.477-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.477-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.478-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.478-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.478-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.478-0800: [GC (CMS Final Remark) [YG occupancy: 70018 K (78656 K)]2020-10-28T17:33:45.478-0800: [Rescan (parallel) , 0.0002879 secs]2020-10-28T17:33:45.478-0800: [weak refs processing, 0.0000124 secs]2020-10-28T17:33:45.478-0800: [class unloading, 0.0001802 secs]2020-10-28T17:33:45.478-0800: [scrub symbol table, 0.0002851 secs]2020-10-28T17:33:45.479-0800: [scrub string table, 0.0001183 secs][1 CMS-remark: 174733K(174784K)] 244752K(253440K), 0.0009289 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.479-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.479-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.479-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.479-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.480-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.480-0800: [ParNew: 78644K->78644K(78656K), 0.0000158 secs]2020-10-28T17:33:45.480-0800: [CMS: 174733K->174291K(174784K), 0.0287811 secs] 253377K->234981K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0288357 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 2020-10-28T17:33:45.509-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174291K(174784K)] 235105K(253440K), 0.0002453 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2020-10-28T17:33:45.510-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.511-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.511-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.512-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.512-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.512-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.512-0800: [GC (CMS Final Remark) [YG occupancy: 71131 K (78656 K)]2020-10-28T17:33:45.512-0800: [Rescan (parallel) , 0.0009001 secs]2020-10-28T17:33:45.513-0800: [weak refs processing, 0.0000123 secs]2020-10-28T17:33:45.513-0800: [class unloading, 0.0002222 secs]2020-10-28T17:33:45.513-0800: [scrub symbol table, 0.0003162 secs]2020-10-28T17:33:45.513-0800: [scrub string table, 0.0001197 secs][1 CMS-remark: 174291K(174784K)] 245422K(253440K), 0.0016286 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.513-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.514-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.514-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.514-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.515-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.515-0800: [ParNew: 78404K->78404K(78656K), 0.0000159 secs]2020-10-28T17:33:45.515-0800: [CMS: 174291K->174610K(174784K), 0.0273834 secs] 252695K->238833K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0274364 secs] [Times: user=0.02 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.542-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174610K(174784K)] 239633K(253440K), 0.0002133 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.543-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.543-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.543-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.544-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.544-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.544-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.544-0800: [GC (CMS Final Remark) [YG occupancy: 73941 K (78656 K)]2020-10-28T17:33:45.544-0800: [Rescan (parallel) , 0.0002855 secs]2020-10-28T17:33:45.545-0800: [weak refs processing, 0.0000124 secs]2020-10-28T17:33:45.545-0800: [class unloading, 0.0001815 secs]2020-10-28T17:33:45.545-0800: [scrub symbol table, 0.0002852 secs]2020-10-28T17:33:45.545-0800: [scrub string table, 0.0001184 secs][1 CMS-remark: 174610K(174784K)] 248551K(253440K), 0.0009285 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.545-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.546-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.546-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.546-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.546-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.546-0800: [ParNew: 78646K->78646K(78656K), 0.0000158 secs]2020-10-28T17:33:45.546-0800: [CMS: 174610K->174406K(174784K), 0.0266180 secs] 253257K->239979K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0266723 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.573-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174406K(174784K)] 239997K(253440K), 0.0002971 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.574-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.574-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.574-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.575-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.575-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.575-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.575-0800: [GC (CMS Final Remark) [YG occupancy: 75041 K (78656 K)]2020-10-28T17:33:45.575-0800: [Rescan (parallel) , 0.0001852 secs]2020-10-28T17:33:45.576-0800: [weak refs processing, 0.0000106 secs]2020-10-28T17:33:45.576-0800: [class unloading, 0.0001988 secs]2020-10-28T17:33:45.576-0800: [scrub symbol table, 0.0002976 secs]2020-10-28T17:33:45.576-0800: [scrub string table, 0.0001208 secs][1 CMS-remark: 174406K(174784K)] 249447K(253440K), 0.0008575 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.576-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.577-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.577-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.577-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.577-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.577-0800: [ParNew: 78494K->78494K(78656K), 0.0000190 secs]2020-10-28T17:33:45.577-0800: [CMS: 174406K->174521K(174784K), 0.0302419 secs] 252901K->241570K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0303011 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.608-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174521K(174784K)] 241755K(253440K), 0.0002363 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.608-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.609-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.609-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.610-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2020-10-28T17:33:45.610-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:33:45.610-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.610-0800: [GC (CMS Final Remark) [YG occupancy: 75939 K (78656 K)]2020-10-28T17:33:45.610-0800: [Rescan (parallel) , 0.0009214 secs]2020-10-28T17:33:45.611-0800: [weak refs processing, 0.0000155 secs]2020-10-28T17:33:45.611-0800: [class unloading, 0.0002091 secs]2020-10-28T17:33:45.611-0800: [scrub symbol table, 0.0002963 secs]2020-10-28T17:33:45.611-0800: [scrub string table, 0.0001188 secs][1 CMS-remark: 174521K(174784K)] 250461K(253440K), 0.0016151 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.612-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:33:45.612-0800: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.612-0800: [CMS-concurrent-reset-start] 2020-10-28T17:33:45.612-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.612-0800: [GC (Allocation Failure) 2020-10-28T17:33:45.612-0800: [ParNew: 78558K->78558K(78656K), 0.0000164 secs]2020-10-28T17:33:45.612-0800: [CMS: 174047K->174753K(174784K), 0.0285343 secs] 252605K->242596K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0285882 secs] [Times: user=0.02 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.641-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174753K(174784K)] 242975K(253440K), 0.0002041 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.641-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.642-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.642-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.643-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.643-0800: [CMS2020-10-28T17:33:45.643-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] (concurrent mode failure): 174753K->174313K(174784K), 0.0288081 secs] 253346K->244587K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0288456 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.673-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.673-0800: [CMS: 174736K->174728K(174784K), 0.0275819 secs] 253392K->244147K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0276223 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.701-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174728K(174784K)] 244291K(253440K), 0.0002704 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.701-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.702-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.702-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.702-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.702-0800: [CMS2020-10-28T17:33:45.703-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] (concurrent mode failure): 174728K->174515K(174784K), 0.0282740 secs] 253282K->243814K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0283096 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.733-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.733-0800: [CMS: 174515K->174671K(174784K), 0.0241133 secs] 252965K->245003K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0241569 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 2020-10-28T17:33:45.757-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174671K(174784K)] 245291K(253440K), 0.0002338 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.757-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.758-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.758-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:33:45.759-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.759-0800: [CMS2020-10-28T17:33:45.759-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] (concurrent mode failure): 174671K->174740K(174784K), 0.0154233 secs] 253246K->246730K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0154596 secs] [Times: user=0.01 sys=0.00, real=0.02 secs] 2020-10-28T17:33:45.776-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.776-0800: [CMS: 174740K->174509K(174784K), 0.0273112 secs] 253271K->248338K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0273535 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 2020-10-28T17:33:45.803-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174509K(174784K)] 248482K(253440K), 0.0002266 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.803-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.804-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.804-0800: [CMS2020-10-28T17:33:45.806-0800: [CMS-concurrent-mark: 0.001/0.002 secs] [Times: user=0.00 sys=0.01, real=0.00 secs] (concurrent mode failure): 174653K->174603K(174784K), 0.0328721 secs] 253235K->248619K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0329069 secs] [Times: user=0.03 sys=0.01, real=0.03 secs] 2020-10-28T17:33:45.838-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.838-0800: [CMS: 174603K->174273K(174784K), 0.0315543 secs] 253256K->249009K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0315931 secs] [Times: user=0.03 sys=0.00, real=0.04 secs] 2020-10-28T17:33:45.870-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 174273K(174784K)] 249138K(253440K), 0.0001815 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:33:45.870-0800: [CMS-concurrent-mark-start] 2020-10-28T17:33:45.870-0800: [Full GC (Allocation Failure) 2020-10-28T17:33:45.870-0800: [CMS2020-10-28T17:33:45.872-0800: [CMS-concurrent-mark: 0.001/0.002 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] (concurrent mode failure): 174273K->174642K(174784K), 0.0275340 secs] 252631K->249023K(253440K), [Metaspace: 2678K->2678K(1056768K)], 0.0275720 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 执行结束! 共生成对象次数:4219 Heap par new generation total 78656K, used 75354K [0x00000007b0000000, 0x00000007b5550000, 0x00000007b5550000) eden space 69952K, 100% used [0x00000007b0000000, 0x00000007b4450000, 0x00000007b4450000) from space 8704K, 62% used [0x00000007b4cd0000, 0x00000007b5216b80, 0x00000007b5550000) to space 8704K, 0% used [0x00000007b4450000, 0x00000007b4450000, 0x00000007b4cd0000) concurrent mark-sweep generation total 174784K, used 174642K [0x00000007b5550000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 512M堆内存 CMS GC日志 ``` Learning_notes (main) ✗ java -XX:+UseConcMarkSweepGC -Xms512m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:34:37.004-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.004-0800: [ParNew: 139776K->17472K(157248K), 0.0180339 secs] 139776K->42898K(506816K), 0.0180890 secs] [Times: user=0.05 sys=0.07, real=0.02 secs] 2020-10-28T17:34:37.051-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.051-0800: [ParNew: 157201K->17471K(157248K), 0.0221618 secs] 182627K->89010K(506816K), 0.0222015 secs] [Times: user=0.04 sys=0.10, real=0.02 secs] 2020-10-28T17:34:37.090-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.090-0800: [ParNew: 157247K->17470K(157248K), 0.0353817 secs] 228786K->144028K(506816K), 0.0354200 secs] [Times: user=0.24 sys=0.02, real=0.03 secs] 2020-10-28T17:34:37.144-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.144-0800: [ParNew: 157246K->17470K(157248K), 0.0282565 secs] 283804K->190336K(506816K), 0.0282990 secs] [Times: user=0.19 sys=0.02, real=0.03 secs] 2020-10-28T17:34:37.193-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.193-0800: [ParNew: 157246K->17470K(157248K), 0.0273488 secs] 330112K->233625K(506816K), 0.0273869 secs] [Times: user=0.18 sys=0.01, real=0.03 secs] 2020-10-28T17:34:37.220-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 216154K(349568K)] 234094K(506816K), 0.0002374 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.221-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.223-0800: [CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.01 sys=0.01, real=0.00 secs] 2020-10-28T17:34:37.223-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.224-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.224-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.239-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.239-0800: [ParNew: 157246K->17469K(157248K), 0.0260492 secs] 373401K->274769K(506816K), 0.0260885 secs] [Times: user=0.17 sys=0.01, real=0.03 secs] 2020-10-28T17:34:37.287-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.287-0800: [ParNew: 157245K->17470K(157248K), 0.0288901 secs] 414545K->319415K(506816K), 0.0289264 secs] [Times: user=0.17 sys=0.02, real=0.03 secs] 2020-10-28T17:34:37.335-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.335-0800: [ParNew: 157246K->157246K(157248K), 0.0000193 secs]2020-10-28T17:34:37.335-0800: [CMS2020-10-28T17:34:37.335-0800: [CMS-concurrent-abortable-preclean: 0.005/0.111 secs] [Times: user=0.40 sys=0.03, real=0.11 secs] (concurrent mode failure): 301944K->246242K(349568K), 0.0462978 secs] 459191K->246242K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0463705 secs] [Times: user=0.05 sys=0.00, real=0.05 secs] 2020-10-28T17:34:37.403-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.403-0800: [ParNew: 139776K->17469K(157248K), 0.0072489 secs] 386018K->295018K(506816K), 0.0072919 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] 2020-10-28T17:34:37.410-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 277548K(349568K)] 295090K(506816K), 0.0001786 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.411-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.412-0800: [CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.412-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.414-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.414-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.430-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.430-0800: [ParNew: 157245K->17470K(157248K), 0.0193818 secs] 434794K->339379K(506816K), 0.0195074 secs] [Times: user=0.11 sys=0.01, real=0.02 secs] 2020-10-28T17:34:37.451-0800: [CMS-concurrent-abortable-preclean: 0.002/0.038 secs] [Times: user=0.13 sys=0.01, real=0.04 secs] 2020-10-28T17:34:37.451-0800: [GC (CMS Final Remark) [YG occupancy: 27865 K (157248 K)]2020-10-28T17:34:37.451-0800: [Rescan (parallel) , 0.0006080 secs]2020-10-28T17:34:37.452-0800: [weak refs processing, 0.0000139 secs]2020-10-28T17:34:37.452-0800: [class unloading, 0.0002118 secs]2020-10-28T17:34:37.452-0800: [scrub symbol table, 0.0003040 secs]2020-10-28T17:34:37.453-0800: [scrub string table, 0.0001291 secs][1 CMS-remark: 321908K(349568K)] 349773K(506816K), 0.0013157 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.453-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:34:37.453-0800: [CMS-concurrent-sweep: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.453-0800: [CMS-concurrent-reset-start] 2020-10-28T17:34:37.454-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.469-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.469-0800: [ParNew: 157246K->17471K(157248K), 0.0150700 secs] 445005K->351096K(506816K), 0.0151108 secs] [Times: user=0.10 sys=0.01, real=0.02 secs] 2020-10-28T17:34:37.484-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 333624K(349568K)] 354043K(506816K), 0.0001307 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.484-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.486-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.486-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.487-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.487-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.487-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.487-0800: [GC (CMS Final Remark) [YG occupancy: 39439 K (157248 K)]2020-10-28T17:34:37.487-0800: [Rescan (parallel) , 0.0003806 secs]2020-10-28T17:34:37.487-0800: [weak refs processing, 0.0000131 secs]2020-10-28T17:34:37.487-0800: [class unloading, 0.0001978 secs]2020-10-28T17:34:37.488-0800: [scrub symbol table, 0.0002877 secs]2020-10-28T17:34:37.488-0800: [scrub string table, 0.0001189 secs][1 CMS-remark: 333624K(349568K)] 373064K(506816K), 0.0010454 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.488-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:34:37.489-0800: [CMS-concurrent-sweep: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.489-0800: [CMS-concurrent-reset-start] 2020-10-28T17:34:37.489-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.505-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.505-0800: [ParNew: 157233K->17467K(157248K), 0.0083362 secs] 425993K->326928K(506816K), 0.0083851 secs] [Times: user=0.06 sys=0.00, real=0.01 secs] 2020-10-28T17:34:37.513-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 309460K(349568K)] 327228K(506816K), 0.0002177 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.514-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.515-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.515-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.516-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.516-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.532-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.532-0800: [ParNew: 157243K->157243K(157248K), 0.0000199 secs]2020-10-28T17:34:37.532-0800: [CMS2020-10-28T17:34:37.532-0800: [CMS-concurrent-abortable-preclean: 0.001/0.016 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] (concurrent mode failure): 309460K->311995K(349568K), 0.0478763 secs] 466704K->311995K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0479520 secs] [Times: user=0.05 sys=0.00, real=0.05 secs] 2020-10-28T17:34:37.601-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.601-0800: [ParNew: 139776K->17468K(157248K), 0.0100901 secs] 451771K->357906K(506816K), 0.0101320 secs] [Times: user=0.07 sys=0.00, real=0.01 secs] 2020-10-28T17:34:37.611-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 340437K(349568K)] 358050K(506816K), 0.0001868 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.612-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.613-0800: [CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.613-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.614-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.614-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.614-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.614-0800: [GC (CMS Final Remark) [YG occupancy: 34304 K (157248 K)]2020-10-28T17:34:37.614-0800: [Rescan (parallel) , 0.0006964 secs]2020-10-28T17:34:37.615-0800: [weak refs processing, 0.0000184 secs]2020-10-28T17:34:37.615-0800: [class unloading, 0.0002460 secs]2020-10-28T17:34:37.615-0800: [scrub symbol table, 0.0003219 secs]2020-10-28T17:34:37.616-0800: [scrub string table, 0.0001331 secs][1 CMS-remark: 340437K(349568K)] 374742K(506816K), 0.0014780 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.616-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:34:37.617-0800: [CMS-concurrent-sweep: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.617-0800: [CMS-concurrent-reset-start] 2020-10-28T17:34:37.617-0800: [CMS-concurrent-reset: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.634-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.634-0800: [ParNew: 156990K->17471K(157248K), 0.0106351 secs] 458469K->359947K(506816K), 0.0106848 secs] [Times: user=0.07 sys=0.00, real=0.01 secs] 2020-10-28T17:34:37.645-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 342475K(349568K)] 360667K(506816K), 0.0002456 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.645-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.647-0800: [CMS-concurrent-mark: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.647-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.648-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.648-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.648-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.648-0800: [GC (CMS Final Remark) [YG occupancy: 36313 K (157248 K)]2020-10-28T17:34:37.648-0800: [Rescan (parallel) , 0.0010329 secs]2020-10-28T17:34:37.649-0800: [weak refs processing, 0.0000131 secs]2020-10-28T17:34:37.649-0800: [class unloading, 0.0001989 secs]2020-10-28T17:34:37.649-0800: [scrub symbol table, 0.0003559 secs]2020-10-28T17:34:37.650-0800: [scrub string table, 0.0001291 secs][1 CMS-remark: 342475K(349568K)] 378789K(506816K), 0.0017936 secs] [Times: user=0.01 sys=0.01, real=0.01 secs] 2020-10-28T17:34:37.650-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:34:37.651-0800: [CMS-concurrent-sweep: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.651-0800: [CMS-concurrent-reset-start] 2020-10-28T17:34:37.651-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.665-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.665-0800: [ParNew: 157247K->157247K(157248K), 0.0000210 secs]2020-10-28T17:34:37.666-0800: [CMS: 302863K->325511K(349568K), 0.0475952 secs] 460111K->325511K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0476769 secs] [Times: user=0.05 sys=0.00, real=0.05 secs] 2020-10-28T17:34:37.713-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 325511K(349568K)] 326171K(506816K), 0.0002271 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.714-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.715-0800: [CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.715-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.716-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.716-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.736-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.736-0800: [ParNew: 139776K->139776K(157248K), 0.0000258 secs]2020-10-28T17:34:37.736-0800: [CMS2020-10-28T17:34:37.736-0800: [CMS-concurrent-abortable-preclean: 0.001/0.019 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] (concurrent mode failure): 325511K->326846K(349568K), 0.0503374 secs] 465287K->326846K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0504517 secs] [Times: user=0.05 sys=0.00, real=0.05 secs] 2020-10-28T17:34:37.811-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.811-0800: [ParNew: 139776K->139776K(157248K), 0.0000221 secs]2020-10-28T17:34:37.811-0800: [CMS: 326846K->333566K(349568K), 0.0517201 secs] 466622K->333566K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0517984 secs] [Times: user=0.05 sys=0.00, real=0.05 secs] 2020-10-28T17:34:37.862-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 333566K(349568K)] 333633K(506816K), 0.0002379 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.863-0800: [CMS-concurrent-mark-start] 2020-10-28T17:34:37.864-0800: [CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.864-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:34:37.865-0800: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.865-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:34:37.865-0800: [CMS-concurrent-abortable-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.866-0800: [GC (CMS Final Remark) [YG occupancy: 16032 K (157248 K)]2020-10-28T17:34:37.866-0800: [Rescan (parallel) , 0.0015116 secs]2020-10-28T17:34:37.867-0800: [weak refs processing, 0.0000157 secs]2020-10-28T17:34:37.867-0800: [class unloading, 0.0002300 secs]2020-10-28T17:34:37.867-0800: [scrub symbol table, 0.0003221 secs]2020-10-28T17:34:37.868-0800: [scrub string table, 0.0001433 secs][1 CMS-remark: 333566K(349568K)] 349599K(506816K), 0.0022784 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.868-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:34:37.869-0800: [CMS-concurrent-sweep: 0.001/0.001 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.869-0800: [CMS-concurrent-reset-start] 2020-10-28T17:34:37.869-0800: [CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.888-0800: [GC (Allocation Failure) 2020-10-28T17:34:37.888-0800: [ParNew: 139776K->139776K(157248K), 0.0000197 secs]2020-10-28T17:34:37.888-0800: [CMS: 333234K->330188K(349568K), 0.0478397 secs] 473010K->330188K(506816K), [Metaspace: 2678K->2678K(1056768K)], 0.0479126 secs] [Times: user=0.04 sys=0.00, real=0.05 secs] 2020-10-28T17:34:37.936-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 330188K(349568K)] 330332K(506816K), 0.0002126 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:34:37.936-0800: [CMS-concurrent-mark-start] 执行结束! 共生成对象次数:10046 Heap par new generation total 157248K, used 5716K [0x00000007a0000000, 0x00000007aaaa0000, 0x00000007aaaa0000) eden space 139776K, 4% used [0x00000007a0000000, 0x00000007a0595118, 0x00000007a8880000) from space 17472K, 0% used [0x00000007a9990000, 0x00000007a9990000, 0x00000007aaaa0000) to space 17472K, 0% used [0x00000007a8880000, 0x00000007a8880000, 0x00000007a9990000) concurrent mark-sweep generation total 349568K, used 330188K [0x00000007aaaa0000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 1G堆内存 CMS GC日志 ``` java -XX:+UseConcMarkSweepGC -Xms1g -Xmx1g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:35:15.474-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.474-0800: [ParNew: 279616K->34944K(314560K), 0.0333906 secs] 279616K->82192K(1013632K), 0.0334438 secs] [Times: user=0.06 sys=0.15, real=0.03 secs] 2020-10-28T17:35:15.552-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.552-0800: [ParNew: 314560K->34943K(314560K), 0.0341288 secs] 361808K->154368K(1013632K), 0.0341690 secs] [Times: user=0.07 sys=0.15, real=0.03 secs] 2020-10-28T17:35:15.626-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.626-0800: [ParNew: 314559K->34942K(314560K), 0.0461409 secs] 433984K->229119K(1013632K), 0.0461815 secs] [Times: user=0.31 sys=0.03, real=0.05 secs] 2020-10-28T17:35:15.707-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.707-0800: [ParNew: 314558K->34942K(314560K), 0.0432460 secs] 508735K->297408K(1013632K), 0.0432852 secs] [Times: user=0.27 sys=0.03, real=0.05 secs] 2020-10-28T17:35:15.786-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.786-0800: [ParNew: 314558K->34942K(314560K), 0.0577662 secs] 577024K->389203K(1013632K), 0.0578405 secs] [Times: user=0.34 sys=0.04, real=0.06 secs] 2020-10-28T17:35:15.844-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 354260K(699072K)] 389714K(1013632K), 0.0003405 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:35:15.844-0800: [CMS-concurrent-mark-start] 2020-10-28T17:35:15.848-0800: [CMS-concurrent-mark: 0.004/0.004 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:35:15.848-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:35:15.849-0800: [CMS-concurrent-preclean: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:35:15.849-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:35:15.886-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.886-0800: [ParNew: 314558K->34942K(314560K), 0.0515069 secs] 668819K->474648K(1013632K), 0.0515445 secs] [Times: user=0.36 sys=0.03, real=0.05 secs] 2020-10-28T17:35:15.976-0800: [GC (Allocation Failure) 2020-10-28T17:35:15.976-0800: [ParNew: 314558K->34943K(314560K), 0.0471178 secs] 754264K->551653K(1013632K), 0.0471580 secs] [Times: user=0.31 sys=0.03, real=0.05 secs] 2020-10-28T17:35:16.059-0800: [GC (Allocation Failure) 2020-10-28T17:35:16.059-0800: [ParNew: 314559K->34943K(314560K), 0.0500496 secs] 831269K->631245K(1013632K), 0.0500870 secs] [Times: user=0.33 sys=0.03, real=0.05 secs] 2020-10-28T17:35:16.146-0800: [GC (Allocation Failure) 2020-10-28T17:35:16.146-0800: [ParNew: 314559K->34942K(314560K), 0.0508076 secs] 910861K->711752K(1013632K), 0.0508448 secs] [Times: user=0.31 sys=0.03, real=0.05 secs] 2020-10-28T17:35:16.196-0800: [CMS-concurrent-abortable-preclean: 0.013/0.347 secs] [Times: user=1.47 sys=0.12, real=0.35 secs] 2020-10-28T17:35:16.197-0800: [GC (CMS Final Remark) [YG occupancy: 40814 K (314560 K)]2020-10-28T17:35:16.197-0800: [Rescan (parallel) , 0.0006218 secs]2020-10-28T17:35:16.197-0800: [weak refs processing, 0.0000178 secs]2020-10-28T17:35:16.197-0800: [class unloading, 0.0002649 secs]2020-10-28T17:35:16.198-0800: [scrub symbol table, 0.0002867 secs]2020-10-28T17:35:16.198-0800: [scrub string table, 0.0001163 secs][1 CMS-remark: 676810K(699072K)] 717625K(1013632K), 0.0013753 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:35:16.198-0800: [CMS-concurrent-sweep-start] 2020-10-28T17:35:16.199-0800: [CMS-concurrent-sweep: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 2020-10-28T17:35:16.200-0800: [CMS-concurrent-reset-start] 2020-10-28T17:35:16.201-0800: [CMS-concurrent-reset: 0.002/0.002 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:35:16.234-0800: [GC (Allocation Failure) 2020-10-28T17:35:16.234-0800: [ParNew: 314558K->34942K(314560K), 0.0189829 secs] 868675K->672514K(1013632K), 0.0190210 secs] [Times: user=0.13 sys=0.01, real=0.02 secs] 2020-10-28T17:35:16.253-0800: [GC (CMS Initial Mark) [1 CMS-initial-mark: 637571K(699072K)] 678248K(1013632K), 0.0001667 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:35:16.254-0800: [CMS-concurrent-mark-start] 2020-10-28T17:35:16.256-0800: [CMS-concurrent-mark: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 2020-10-28T17:35:16.256-0800: [CMS-concurrent-preclean-start] 2020-10-28T17:35:16.258-0800: [CMS-concurrent-preclean: 0.002/0.002 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-10-28T17:35:16.258-0800: [CMS-concurrent-abortable-preclean-start] 2020-10-28T17:35:16.297-0800: [GC (Allocation Failure) 2020-10-28T17:35:16.297-0800: [ParNew: 314558K->314558K(314560K), 0.0000197 secs]2020-10-28T17:35:16.297-0800: [CMS2020-10-28T17:35:16.297-0800: [CMS-concurrent-abortable-preclean: 0.002/0.039 secs] [Times: user=0.04 sys=0.00, real=0.04 secs] (concurrent mode failure): 637571K->352133K(699072K), 0.0650754 secs] 952130K->352133K(1013632K), [Metaspace: 2678K->2678K(1056768K)], 0.0651509 secs] [Times: user=0.06 sys=0.00, real=0.07 secs] 执行结束! 共生成对象次数:11698 Heap par new generation total 314560K, used 11474K [0x0000000780000000, 0x0000000795550000, 0x0000000795550000) eden space 279616K, 4% used [0x0000000780000000, 0x0000000780b34a50, 0x0000000791110000) from space 34944K, 0% used [0x0000000791110000, 0x0000000791110000, 0x0000000793330000) to space 34944K, 0% used [0x0000000793330000, 0x0000000793330000, 0x0000000795550000) concurrent mark-sweep generation total 699072K, used 352133K [0x0000000795550000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 2G堆内存 CMS GC日志 ``` ava -XX:+UseConcMarkSweepGC -Xms2g -Xmx2g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:35:39.476-0800: [GC (Allocation Failure) 2020-10-28T17:35:39.477-0800: [ParNew: 545344K->68096K(613440K), 0.0640574 secs] 545344K->154929K(2029056K), 0.0641104 secs] [Times: user=0.10 sys=0.22, real=0.07 secs] 2020-10-28T17:35:39.627-0800: [GC (Allocation Failure) 2020-10-28T17:35:39.627-0800: [ParNew: 613440K->68096K(613440K), 0.0747146 secs] 700273K->284573K(2029056K), 0.0747553 secs] [Times: user=0.12 sys=0.25, real=0.08 secs] 2020-10-28T17:35:39.778-0800: [GC (Allocation Failure) 2020-10-28T17:35:39.778-0800: [ParNew: 613440K->68096K(613440K), 0.0916658 secs] 829917K->408641K(2029056K), 0.0917110 secs] [Times: user=0.43 sys=0.04, real=0.10 secs] 2020-10-28T17:35:39.942-0800: [GC (Allocation Failure) 2020-10-28T17:35:39.942-0800: [ParNew: 613440K->68095K(613440K), 0.0988522 secs] 953985K->539393K(2029056K), 0.0988923 secs] [Times: user=0.45 sys=0.05, real=0.10 secs] 2020-10-28T17:35:40.115-0800: [GC (Allocation Failure) 2020-10-28T17:35:40.115-0800: [ParNew: 613439K->68095K(613440K), 0.0856929 secs] 1084737K->666780K(2029056K), 0.0857357 secs] [Times: user=0.56 sys=0.04, real=0.09 secs] 执行结束! 共生成对象次数:10173 Heap par new generation total 613440K, used 90041K [0x0000000740000000, 0x0000000769990000, 0x0000000769990000) eden space 545344K, 4% used [0x0000000740000000, 0x000000074156e9f8, 0x0000000761490000) from space 68096K, 99% used [0x0000000765710000, 0x000000076998fc98, 0x0000000769990000) to space 68096K, 0% used [0x0000000761490000, 0x0000000761490000, 0x0000000765710000) concurrent mark-sweep generation total 1415616K, used 598685K [0x0000000769990000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 4G堆内存 CMS GC日志 ``` Learning_notes (main) ✗ java -XX:+UseConcMarkSweepGC -Xms4g -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:36:09.754-0800: [GC (Allocation Failure) 2020-10-28T17:36:09.754-0800: [ParNew: 545344K->68096K(613440K), 0.0659369 secs] 545344K->155326K(4126208K), 0.0659897 secs] [Times: user=0.13 sys=0.29, real=0.07 secs] 2020-10-28T17:36:09.896-0800: [GC (Allocation Failure) 2020-10-28T17:36:09.896-0800: [ParNew: 613440K->68096K(613440K), 0.0668243 secs] 700670K->275230K(4126208K), 0.0668700 secs] [Times: user=0.13 sys=0.28, real=0.07 secs] 2020-10-28T17:36:10.044-0800: [GC (Allocation Failure) 2020-10-28T17:36:10.044-0800: [ParNew: 613440K->68096K(613440K), 0.0886651 secs] 820574K->401453K(4126208K), 0.0887019 secs] [Times: user=0.56 sys=0.05, real=0.09 secs] 2020-10-28T17:36:10.209-0800: [GC (Allocation Failure) 2020-10-28T17:36:10.209-0800: [ParNew: 613440K->68095K(613440K), 0.0785825 secs] 946797K->515421K(4126208K), 0.0786190 secs] [Times: user=0.51 sys=0.05, real=0.08 secs] 2020-10-28T17:36:10.365-0800: [GC (Allocation Failure) 2020-10-28T17:36:10.365-0800: [ParNew: 613000K->68095K(613440K), 0.0803197 secs] 1060326K->643368K(4126208K), 0.0803556 secs] [Times: user=0.52 sys=0.05, real=0.08 secs] 执行结束! 共生成对象次数:10215 Heap par new generation total 613440K, used 90448K [0x00000006c0000000, 0x00000006e9990000, 0x00000006e9990000) eden space 545344K, 4% used [0x00000006c0000000, 0x00000006c15d4570, 0x00000006e1490000) from space 68096K, 99% used [0x00000006e5710000, 0x00000006e998fe18, 0x00000006e9990000) to space 68096K, 0% used [0x00000006e1490000, 0x00000006e1490000, 0x00000006e5710000) concurrent mark-sweep generation total 3512768K, used 575273K [0x00000006e9990000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ### 8G堆内存 CMS GC日志 ``` Learning_notes (main) ✗ java -XX:+UseConcMarkSweepGC -Xms8g -Xmx8g -XX:+PrintGCDetails -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:36:50.125-0800: [GC (Allocation Failure) 2020-10-28T17:36:50.125-0800: [ParNew: 545344K->68095K(613440K), 0.0788707 secs] 545344K->142091K(8320512K), 0.0789218 secs] [Times: user=0.19 sys=0.26, real=0.08 secs] 2020-10-28T17:36:50.286-0800: [GC (Allocation Failure) 2020-10-28T17:36:50.286-0800: [ParNew: 613439K->68092K(613440K), 0.0959894 secs] 687435K->282958K(8320512K), 0.0960330 secs] [Times: user=0.24 sys=0.34, real=0.10 secs] 2020-10-28T17:36:50.458-0800: [GC (Allocation Failure) 2020-10-28T17:36:50.458-0800: [ParNew: 613436K->68095K(613440K), 0.0957797 secs] 828302K->401465K(8320512K), 0.0958477 secs] [Times: user=0.63 sys=0.04, real=0.10 secs] 2020-10-28T17:36:50.633-0800: [GC (Allocation Failure) 2020-10-28T17:36:50.633-0800: [ParNew: 613439K->68095K(613440K), 0.0910626 secs] 946809K->517784K(8320512K), 0.0911013 secs] [Times: user=0.60 sys=0.05, real=0.09 secs] 2020-10-28T17:36:50.800-0800: [GC (Allocation Failure) 2020-10-28T17:36:50.800-0800: [ParNew: 613439K->68095K(613440K), 0.0978195 secs] 1063128K->649032K(8320512K), 0.0978563 secs] [Times: user=0.63 sys=0.05, real=0.09 secs] 执行结束! 共生成对象次数:10318 Heap par new generation total 613440K, used 90119K [0x00000005c0000000, 0x00000005e9990000, 0x00000005e9990000) eden space 545344K, 4% used [0x00000005c0000000, 0x00000005c1581f30, 0x00000005e1490000) from space 68096K, 99% used [0x00000005e5710000, 0x00000005e998fd88, 0x00000005e9990000) to space 68096K, 0% used [0x00000005e1490000, 0x00000005e1490000, 0x00000005e5710000) concurrent mark-sweep generation total 7707072K, used 580937K [0x00000005e9990000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2684K, capacity 4486K, committed 4864K, reserved 1056768K class space used 294K, capacity 386K, committed 512K, reserved 1048576K ``` ## G1 GC日志 ### 256M堆内存 G1 GC日志 ``` Learning_notes (main) ✗ java -XX:+UseG1GC -Xms256m -Xmx256m -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:37:22.423-0800: [GC pause (G1 Evacuation Pause) (young) 34M->13M(256M), 0.0048383 secs] 2020-10-28T17:37:22.439-0800: [GC pause (G1 Evacuation Pause) (young) 45M->23M(256M), 0.0044306 secs] 2020-10-28T17:37:22.456-0800: [GC pause (G1 Evacuation Pause) (young) 66M->37M(256M), 0.0059509 secs] 2020-10-28T17:37:22.492-0800: [GC pause (G1 Evacuation Pause) (young) 114M->61M(256M), 0.0076887 secs] 2020-10-28T17:37:22.538-0800: [GC pause (G1 Evacuation Pause) (young) 176M->99M(256M), 0.0132035 secs] 2020-10-28T17:37:22.556-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 130M->111M(256M), 0.0034839 secs] 2020-10-28T17:37:22.559-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.560-0800: [GC concurrent-root-region-scan-end, 0.0001663 secs] 2020-10-28T17:37:22.560-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.561-0800: [GC concurrent-mark-end, 0.0011127 secs] 2020-10-28T17:37:22.561-0800: [GC remark, 0.0009107 secs] 2020-10-28T17:37:22.562-0800: [GC cleanup 121M->121M(256M), 0.0004876 secs] 2020-10-28T17:37:22.581-0800: [GC pause (G1 Evacuation Pause) (young) 198M->136M(256M), 0.0039608 secs] 2020-10-28T17:37:22.586-0800: [GC pause (G1 Evacuation Pause) (mixed) 141M->136M(256M), 0.0016775 secs] 2020-10-28T17:37:22.588-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 139M->137M(256M), 0.0014148 secs] 2020-10-28T17:37:22.589-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.589-0800: [GC concurrent-root-region-scan-end, 0.0001143 secs] 2020-10-28T17:37:22.589-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.590-0800: [GC concurrent-mark-end, 0.0006579 secs] 2020-10-28T17:37:22.590-0800: [GC remark, 0.0010572 secs] 2020-10-28T17:37:22.591-0800: [GC cleanup 144M->144M(256M), 0.0004859 secs] 2020-10-28T17:37:22.603-0800: [GC pause (G1 Evacuation Pause) (young)-- 213M->189M(256M), 0.0021860 secs] 2020-10-28T17:37:22.606-0800: [GC pause (G1 Evacuation Pause) (mixed) 194M->184M(256M), 0.0024652 secs] 2020-10-28T17:37:22.609-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 187M->184M(256M), 0.0011838 secs] 2020-10-28T17:37:22.610-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.610-0800: [GC concurrent-root-region-scan-end, 0.0001059 secs] 2020-10-28T17:37:22.610-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.611-0800: [GC concurrent-mark-end, 0.0007120 secs] 2020-10-28T17:37:22.611-0800: [GC remark, 0.0009987 secs] 2020-10-28T17:37:22.612-0800: [GC cleanup 190M->190M(256M), 0.0004167 secs] 2020-10-28T17:37:22.614-0800: [GC pause (G1 Evacuation Pause) (young) 202M->190M(256M), 0.0013174 secs] 2020-10-28T17:37:22.618-0800: [GC pause (G1 Evacuation Pause) (mixed) 202M->172M(256M), 0.0017245 secs] 2020-10-28T17:37:22.621-0800: [GC pause (G1 Evacuation Pause) (mixed) 183M->166M(256M), 0.0028578 secs] 2020-10-28T17:37:22.625-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 170M->167M(256M), 0.0010604 secs] 2020-10-28T17:37:22.626-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.627-0800: [GC concurrent-root-region-scan-end, 0.0000770 secs] 2020-10-28T17:37:22.627-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.627-0800: [GC concurrent-mark-end, 0.0006284 secs] 2020-10-28T17:37:22.627-0800: [GC remark, 0.0010385 secs] 2020-10-28T17:37:22.629-0800: [GC cleanup 172M->172M(256M), 0.0005355 secs] 2020-10-28T17:37:22.633-0800: [GC pause (G1 Evacuation Pause) (young) 199M->178M(256M), 0.0027134 secs] 2020-10-28T17:37:22.638-0800: [GC pause (G1 Evacuation Pause) (mixed) 190M->176M(256M), 0.0030229 secs] 2020-10-28T17:37:22.642-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 177M->177M(256M), 0.0015703 secs] 2020-10-28T17:37:22.643-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.643-0800: [GC concurrent-root-region-scan-end, 0.0000494 secs] 2020-10-28T17:37:22.643-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.644-0800: [GC concurrent-mark-end, 0.0006969 secs] 2020-10-28T17:37:22.644-0800: [GC remark, 0.0010297 secs] 2020-10-28T17:37:22.645-0800: [GC cleanup 182M->182M(256M), 0.0005346 secs] 2020-10-28T17:37:22.649-0800: [GC pause (G1 Evacuation Pause) (young) 200M->187M(256M), 0.0013357 secs] 2020-10-28T17:37:22.652-0800: [GC pause (G1 Evacuation Pause) (mixed) 201M->189M(256M), 0.0029987 secs] 2020-10-28T17:37:22.655-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 190M->187M(256M), 0.0015820 secs] 2020-10-28T17:37:22.657-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.657-0800: [GC concurrent-root-region-scan-end, 0.0001104 secs] 2020-10-28T17:37:22.657-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.658-0800: [GC concurrent-mark-end, 0.0007464 secs] 2020-10-28T17:37:22.658-0800: [GC remark, 0.0009473 secs] 2020-10-28T17:37:22.659-0800: [GC cleanup 191M->191M(256M), 0.0004492 secs] 2020-10-28T17:37:22.661-0800: [GC pause (G1 Evacuation Pause) (young) 201M->191M(256M), 0.0016871 secs] 2020-10-28T17:37:22.665-0800: [GC pause (G1 Evacuation Pause) (mixed) 204M->192M(256M), 0.0019996 secs] 2020-10-28T17:37:22.668-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 193M->192M(256M), 0.0009262 secs] 2020-10-28T17:37:22.669-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.669-0800: [GC concurrent-root-region-scan-end, 0.0001438 secs] 2020-10-28T17:37:22.669-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.669-0800: [GC concurrent-mark-end, 0.0007325 secs] 2020-10-28T17:37:22.670-0800: [GC remark, 0.0009095 secs] 2020-10-28T17:37:22.671-0800: [GC cleanup 198M->198M(256M), 0.0004869 secs] 2020-10-28T17:37:22.672-0800: [GC pause (G1 Evacuation Pause) (young) 205M->196M(256M), 0.0012129 secs] 2020-10-28T17:37:22.676-0800: [GC pause (G1 Evacuation Pause) (mixed) 208M->196M(256M), 0.0016569 secs] 2020-10-28T17:37:22.677-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 197M->196M(256M), 0.0009397 secs] 2020-10-28T17:37:22.678-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.679-0800: [GC concurrent-root-region-scan-end, 0.0001129 secs] 2020-10-28T17:37:22.679-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.679-0800: [GC concurrent-mark-end, 0.0007756 secs] 2020-10-28T17:37:22.679-0800: [GC remark, 0.0009564 secs] 2020-10-28T17:37:22.680-0800: [GC cleanup 203M->203M(256M), 0.0004095 secs] 2020-10-28T17:37:22.682-0800: [GC pause (G1 Evacuation Pause) (young) 209M->200M(256M), 0.0012112 secs] 2020-10-28T17:37:22.685-0800: [GC pause (G1 Evacuation Pause) (mixed)-- 211M->212M(256M), 0.0024716 secs] 2020-10-28T17:37:22.688-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 213M->212M(256M), 0.0008451 secs] 2020-10-28T17:37:22.689-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.689-0800: [GC concurrent-root-region-scan-end, 0.0000989 secs] 2020-10-28T17:37:22.689-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.690-0800: [GC concurrent-mark-end, 0.0007401 secs] 2020-10-28T17:37:22.690-0800: [GC remark, 0.0009561 secs] 2020-10-28T17:37:22.691-0800: [GC cleanup 219M->219M(256M), 0.0004786 secs] 2020-10-28T17:37:22.692-0800: [GC pause (G1 Evacuation Pause) (young)-- 221M->218M(256M), 0.0012382 secs] 2020-10-28T17:37:22.694-0800: [GC pause (G1 Evacuation Pause) (mixed)-- 221M->221M(256M), 0.0009174 secs] 2020-10-28T17:37:22.695-0800: [Full GC (Allocation Failure) 221M->181M(256M), 0.0206145 secs] 2020-10-28T17:37:22.716-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 185M->183M(256M), 0.0007964 secs] 2020-10-28T17:37:22.717-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.717-0800: [GC concurrent-root-region-scan-end, 0.0001004 secs] 2020-10-28T17:37:22.717-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.718-0800: [GC concurrent-mark-end, 0.0006509 secs] 2020-10-28T17:37:22.718-0800: [GC remark, 0.0009775 secs] 2020-10-28T17:37:22.719-0800: [GC cleanup 186M->186M(256M), 0.0004909 secs] 2020-10-28T17:37:22.721-0800: [GC pause (G1 Evacuation Pause) (young) 196M->185M(256M), 0.0019422 secs] 2020-10-28T17:37:22.723-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 185M->184M(256M), 0.0008542 secs] 2020-10-28T17:37:22.724-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.724-0800: [GC concurrent-root-region-scan-end, 0.0000457 secs] 2020-10-28T17:37:22.724-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.725-0800: [GC concurrent-mark-end, 0.0007427 secs] 2020-10-28T17:37:22.725-0800: [GC remark, 0.0010470 secs] 2020-10-28T17:37:22.726-0800: [GC cleanup 190M->190M(256M), 0.0004069 secs] 2020-10-28T17:37:22.729-0800: [GC pause (G1 Evacuation Pause) (young) 199M->189M(256M), 0.0016952 secs] 2020-10-28T17:37:22.732-0800: [GC pause (G1 Evacuation Pause) (mixed)-- 200M->197M(256M), 0.0021431 secs] 2020-10-28T17:37:22.735-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark)-- 204M->202M(256M), 0.0011266 secs] 2020-10-28T17:37:22.737-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.737-0800: [GC concurrent-root-region-scan-end, 0.0001001 secs] 2020-10-28T17:37:22.737-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.737-0800: [GC pause (G1 Evacuation Pause) (young)-- 207M->205M(256M), 0.0008216 secs] 2020-10-28T17:37:22.738-0800: [GC pause (G1 Evacuation Pause) (young) 207M->206M(256M), 0.0006422 secs] 2020-10-28T17:37:22.739-0800: [GC concurrent-mark-end, 0.0023798 secs] 2020-10-28T17:37:22.739-0800: [GC remark, 0.0009216 secs] 2020-10-28T17:37:22.740-0800: [GC cleanup 207M->207M(256M), 0.0003809 secs] 2020-10-28T17:37:22.741-0800: [GC pause (G1 Humongous Allocation) (young)-- 207M->207M(256M), 0.0005999 secs] 2020-10-28T17:37:22.741-0800: [Full GC (Allocation Failure) 207M->189M(256M), 0.0174892 secs] 2020-10-28T17:37:22.759-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 190M->190M(256M), 0.0007944 secs] 2020-10-28T17:37:22.760-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.760-0800: [GC concurrent-root-region-scan-end, 0.0000139 secs] 2020-10-28T17:37:22.760-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.761-0800: [GC concurrent-mark-end, 0.0011157 secs] 2020-10-28T17:37:22.761-0800: [GC remark, 0.0012788 secs] 2020-10-28T17:37:22.762-0800: [GC cleanup 197M->197M(256M), 0.0005430 secs] 2020-10-28T17:37:22.764-0800: [GC pause (G1 Evacuation Pause) (young)-- 202M->197M(256M), 0.0015609 secs] 2020-10-28T17:37:22.766-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 197M->197M(256M), 0.0008603 secs] 2020-10-28T17:37:22.767-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.767-0800: [GC concurrent-root-region-scan-end, 0.0000166 secs] 2020-10-28T17:37:22.767-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.768-0800: [GC concurrent-mark-end, 0.0008705 secs] 2020-10-28T17:37:22.768-0800: [GC remark, 0.0011550 secs] 2020-10-28T17:37:22.769-0800: [GC cleanup 201M->201M(256M), 0.0005837 secs] 2020-10-28T17:37:22.770-0800: [GC pause (G1 Evacuation Pause) (young)-- 203M->203M(256M), 0.0010054 secs] 2020-10-28T17:37:22.772-0800: [GC pause (G1 Evacuation Pause) (mixed)-- 204M->204M(256M), 0.0007069 secs] 2020-10-28T17:37:22.772-0800: [Full GC (Allocation Failure) 204M->193M(256M), 0.0130119 secs] 2020-10-28T17:37:22.786-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 194M->193M(256M), 0.0009890 secs] 2020-10-28T17:37:22.787-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.787-0800: [GC concurrent-root-region-scan-end, 0.0000857 secs] 2020-10-28T17:37:22.787-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.788-0800: [GC concurrent-mark-end, 0.0007937 secs] 2020-10-28T17:37:22.788-0800: [GC remark, 0.0011833 secs] 2020-10-28T17:37:22.789-0800: [GC cleanup 199M->199M(256M), 0.0006437 secs] 2020-10-28T17:37:22.790-0800: [GC pause (G1 Evacuation Pause) (young)-- 202M->199M(256M), 0.0011010 secs] 2020-10-28T17:37:22.792-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 200M->199M(256M), 0.0006747 secs] 2020-10-28T17:37:22.793-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.793-0800: [GC concurrent-root-region-scan-end, 0.0000809 secs] 2020-10-28T17:37:22.793-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.793-0800: [GC pause (G1 Humongous Allocation) (young)-- 202M->202M(256M), 0.0011871 secs] 2020-10-28T17:37:22.794-0800: [Full GC (Allocation Failure) 202M->194M(256M), 0.0067809 secs] 2020-10-28T17:37:22.801-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.801-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 195M->194M(256M), 0.0009116 secs] 2020-10-28T17:37:22.802-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.802-0800: [GC concurrent-root-region-scan-end, 0.0000547 secs] 2020-10-28T17:37:22.802-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.803-0800: [GC concurrent-mark-end, 0.0009542 secs] 2020-10-28T17:37:22.804-0800: [GC remark, 0.0011597 secs] 2020-10-28T17:37:22.805-0800: [GC cleanup 199M->199M(256M), 0.0005163 secs] 2020-10-28T17:37:22.806-0800: [GC pause (G1 Evacuation Pause) (young)-- 200M->198M(256M), 0.0010232 secs] 2020-10-28T17:37:22.807-0800: [GC pause (G1 Evacuation Pause) (mixed)-- 201M->200M(256M), 0.0008563 secs] 2020-10-28T17:37:22.808-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark)-- 201M->201M(256M), 0.0010041 secs] 2020-10-28T17:37:22.809-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.809-0800: [GC concurrent-root-region-scan-end, 0.0000180 secs] 2020-10-28T17:37:22.809-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.809-0800: [GC pause (G1 Humongous Allocation) (young) 201M->201M(256M), 0.0014053 secs] 2020-10-28T17:37:22.811-0800: [Full GC (Allocation Failure) 201M->193M(256M), 0.0168918 secs] 2020-10-28T17:37:22.828-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.828-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 194M->194M(256M), 0.0017985 secs] 2020-10-28T17:37:22.830-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.830-0800: [GC concurrent-root-region-scan-end, 0.0000888 secs] 2020-10-28T17:37:22.830-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.831-0800: [GC concurrent-mark-end, 0.0008460 secs] 2020-10-28T17:37:22.831-0800: [GC remark, 0.0013321 secs] 2020-10-28T17:37:22.833-0800: [GC cleanup 199M->199M(256M), 0.0006151 secs] 2020-10-28T17:37:22.834-0800: [GC pause (G1 Evacuation Pause) (young)-- 202M->201M(256M), 0.0011052 secs] 2020-10-28T17:37:22.835-0800: [GC pause (G1 Evacuation Pause) (young)-- 202M->202M(256M), 0.0009265 secs] 2020-10-28T17:37:22.836-0800: [Full GC (Allocation Failure) 202M->195M(256M), 0.0093894 secs] 2020-10-28T17:37:22.847-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 200M->197M(256M), 0.0009975 secs] 2020-10-28T17:37:22.848-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.848-0800: [GC concurrent-root-region-scan-end, 0.0001283 secs] 2020-10-28T17:37:22.848-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.849-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->201M(256M), 0.0024390 secs] 2020-10-28T17:37:22.852-0800: [Full GC (Allocation Failure) 201M->197M(256M), 0.0138701 secs] 2020-10-28T17:37:22.866-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.868-0800: [GC pause (G1 Evacuation Pause) (young)-- 202M->202M(256M), 0.0011686 secs] 2020-10-28T17:37:22.869-0800: [Full GC (Allocation Failure) 202M->197M(256M), 0.0116869 secs] 2020-10-28T17:37:22.881-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 198M->197M(256M), 0.0010773 secs] 2020-10-28T17:37:22.882-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.882-0800: [GC concurrent-root-region-scan-end, 0.0000829 secs] 2020-10-28T17:37:22.882-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.883-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->199M(256M), 0.0010314 secs] 2020-10-28T17:37:22.884-0800: [GC concurrent-mark-end, 0.0020061 secs] 2020-10-28T17:37:22.884-0800: [GC pause (G1 Humongous Allocation) (young)-- 201M->200M(256M), 0.0008527 secs] 2020-10-28T17:37:22.885-0800: [GC remark, 0.0010484 secs] 2020-10-28T17:37:22.886-0800: [GC pause (G1 Humongous Allocation) (young) 201M->201M(256M), 0.0012749 secs] 2020-10-28T17:37:22.888-0800: [Full GC (Allocation Failure) 201M->199M(256M), 0.0230398 secs] 2020-10-28T17:37:22.911-0800: [GC cleanup, 0.0000207 secs] 2020-10-28T17:37:22.911-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.911-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->200M(256M), 0.0010847 secs] 2020-10-28T17:37:22.913-0800: [GC pause (G1 Evacuation Pause) (young) (initial-mark)-- 201M->201M(256M), 0.0011905 secs] 2020-10-28T17:37:22.914-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.914-0800: [GC concurrent-root-region-scan-end, 0.0000156 secs] 2020-10-28T17:37:22.914-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.914-0800: [Full GC (Allocation Failure) 201M->200M(256M), 0.0108333 secs] 2020-10-28T17:37:22.925-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.925-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 200M->200M(256M), 0.0009512 secs] 2020-10-28T17:37:22.926-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.926-0800: [GC concurrent-root-region-scan-end, 0.0000893 secs] 2020-10-28T17:37:22.926-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.927-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->201M(256M), 0.0015830 secs] 2020-10-28T17:37:22.929-0800: [GC concurrent-mark-end, 0.0024820 secs] 2020-10-28T17:37:22.929-0800: [GC pause (G1 Humongous Allocation) (young)-- 201M->201M(256M), 0.0015715 secs] 2020-10-28T17:37:22.930-0800: [GC remark, 0.0020999 secs] 2020-10-28T17:37:22.933-0800: [Full GC (Allocation Failure) 201M->200M(256M), 0.0029352 secs] 2020-10-28T17:37:22.936-0800: [GC cleanup, 0.0000125 secs] 2020-10-28T17:37:22.936-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.936-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->201M(256M), 0.0016318 secs] 2020-10-28T17:37:22.938-0800: [Full GC (Allocation Failure) 201M->200M(256M), 0.0034248 secs] 2020-10-28T17:37:22.941-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->201M(256M), 0.0019533 secs] 2020-10-28T17:37:22.943-0800: [Full GC (Allocation Failure) 201M->200M(256M), 0.0121218 secs] 2020-10-28T17:37:22.956-0800: [GC pause (G1 Evacuation Pause) (young)-- 201M->201M(256M), 0.0008732 secs] 2020-10-28T17:37:22.957-0800: [Full GC (Allocation Failure) 201M->201M(256M), 0.0037057 secs] 2020-10-28T17:37:22.961-0800: [GC pause (G1 Evacuation Pause) (young)-- 202M->201M(256M), 0.0015933 secs] 2020-10-28T17:37:22.963-0800: [GC pause (G1 Evacuation Pause) (young) (initial-mark)-- 202M->202M(256M), 0.0017500 secs] 2020-10-28T17:37:22.965-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.965-0800: [GC concurrent-root-region-scan-end, 0.0000166 secs] 2020-10-28T17:37:22.965-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.965-0800: [Full GC (Allocation Failure) 202M->200M(256M), 0.0050062 secs] 2020-10-28T17:37:22.970-0800: [Full GC (Allocation Failure) 200M->200M(256M), 0.0028928 secs] 2020-10-28T17:37:22.973-0800: [GC concurrent-mark-abort] 2020-10-28T17:37:22.973-0800: [GC pause (G1 Evacuation Pause) (young) 200M->200M(256M), 0.0009329 secs] 2020-10-28T17:37:22.974-0800: [GC pause (G1 Evacuation Pause) (young) (initial-mark) 200M->200M(256M), 0.0008712 secs] 2020-10-28T17:37:22.975-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:22.975-0800: [GC concurrent-root-region-scan-end, 0.0000142 secs] 2020-10-28T17:37:22.975-0800: [GC concurrent-mark-start] 2020-10-28T17:37:22.975-0800: [Full GC (Allocation Failure) 200M->268K(256M), 0.0025541 secs] 2020-10-28T17:37:22.977-0800: [GC concurrent-mark-abort] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at GCLogAnalysis.generateGarbage(GCLogAnalysis.java:54) at GCLogAnalysis.main(GCLogAnalysis.java:31) ``` ### 512M堆内存 G1 GC日志 ``` Learning_notes (main) ✗ java -XX:+UseG1GC -Xms512m -Xmx512m -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:37:55.464-0800: [GC pause (G1 Evacuation Pause) (young) 30M->11M(512M), 0.0048784 secs] 2020-10-28T17:37:55.475-0800: [GC pause (G1 Evacuation Pause) (young) 37M->19M(512M), 0.0032333 secs] 2020-10-28T17:37:55.503-0800: [GC pause (G1 Evacuation Pause) (young) 75M->37M(512M), 0.0070461 secs] 2020-10-28T17:37:55.700-0800: [GC pause (G1 Evacuation Pause) (young)-- 419M->302M(512M), 0.0168497 secs] 2020-10-28T17:37:55.718-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 304M->304M(512M), 0.0069151 secs] 2020-10-28T17:37:55.725-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:55.725-0800: [GC concurrent-root-region-scan-end, 0.0001642 secs] 2020-10-28T17:37:55.725-0800: [GC concurrent-mark-start] 2020-10-28T17:37:55.727-0800: [GC concurrent-mark-end, 0.0022999 secs] 2020-10-28T17:37:55.727-0800: [GC remark, 0.0010529 secs] 2020-10-28T17:37:55.729-0800: [GC cleanup 318M->318M(512M), 0.0005533 secs] 2020-10-28T17:37:55.756-0800: [GC pause (G1 Evacuation Pause) (young) 437M->346M(512M), 0.0038102 secs] 2020-10-28T17:37:55.763-0800: [GC pause (G1 Evacuation Pause) (mixed) 363M->301M(512M), 0.0029818 secs] 2020-10-28T17:37:55.770-0800: [GC pause (G1 Evacuation Pause) (mixed) 327M->261M(512M), 0.0032122 secs] 2020-10-28T17:37:55.778-0800: [GC pause (G1 Evacuation Pause) (mixed) 285M->229M(512M), 0.0040238 secs] 2020-10-28T17:37:55.786-0800: [GC pause (G1 Evacuation Pause) (mixed) 255M->225M(512M), 0.0026559 secs] 2020-10-28T17:37:55.789-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 226M->225M(512M), 0.0015351 secs] 2020-10-28T17:37:55.790-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:55.791-0800: [GC concurrent-root-region-scan-end, 0.0001215 secs] 2020-10-28T17:37:55.791-0800: [GC concurrent-mark-start] 2020-10-28T17:37:55.791-0800: [GC concurrent-mark-end, 0.0008353 secs] 2020-10-28T17:37:55.791-0800: [GC remark, 0.0013424 secs] 2020-10-28T17:37:55.793-0800: [GC cleanup 230M->229M(512M), 0.0007584 secs] 2020-10-28T17:37:55.794-0800: [GC concurrent-cleanup-start] 2020-10-28T17:37:55.794-0800: [GC concurrent-cleanup-end, 0.0000182 secs] 2020-10-28T17:37:55.829-0800: [GC pause (G1 Evacuation Pause) (young)-- 412M->290M(512M), 0.0064016 secs] 2020-10-28T17:37:55.837-0800: [GC pause (G1 Evacuation Pause) (mixed) 297M->269M(512M), 0.0063431 secs] 2020-10-28T17:37:55.844-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 271M->269M(512M), 0.0022768 secs] 2020-10-28T17:37:55.846-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:55.846-0800: [GC concurrent-root-region-scan-end, 0.0001239 secs] 2020-10-28T17:37:55.846-0800: [GC concurrent-mark-start] 2020-10-28T17:37:55.847-0800: [GC concurrent-mark-end, 0.0011189 secs] 2020-10-28T17:37:55.847-0800: [GC remark, 0.0012422 secs] 2020-10-28T17:37:55.849-0800: [GC cleanup 276M->275M(512M), 0.0007496 secs] 2020-10-28T17:37:55.849-0800: [GC concurrent-cleanup-start] 2020-10-28T17:37:55.849-0800: [GC concurrent-cleanup-end, 0.0000179 secs] 2020-10-28T17:37:55.874-0800: [GC pause (G1 Evacuation Pause) (young) 412M->307M(512M), 0.0047505 secs] 2020-10-28T17:37:55.881-0800: [GC pause (G1 Evacuation Pause) (mixed) 319M->274M(512M), 0.0049773 secs] 2020-10-28T17:37:55.892-0800: [GC pause (G1 Evacuation Pause) (mixed) 298M->282M(512M), 0.0036821 secs] 2020-10-28T17:37:55.896-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 282M->282M(512M), 0.0014887 secs] 2020-10-28T17:37:55.897-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:55.898-0800: [GC concurrent-root-region-scan-end, 0.0001739 secs] 2020-10-28T17:37:55.898-0800: [GC concurrent-mark-start] 2020-10-28T17:37:55.899-0800: [GC concurrent-mark-end, 0.0011575 secs] 2020-10-28T17:37:55.899-0800: [GC remark, 0.0012867 secs] 2020-10-28T17:37:55.900-0800: [GC cleanup 288M->288M(512M), 0.0005778 secs] 2020-10-28T17:37:55.925-0800: [GC pause (G1 Evacuation Pause) (young)-- 420M->330M(512M), 0.0052085 secs] 2020-10-28T17:37:55.932-0800: [GC pause (G1 Evacuation Pause) (mixed) 342M->311M(512M), 0.0057396 secs] 2020-10-28T17:37:55.939-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 316M->312M(512M), 0.0013254 secs] 2020-10-28T17:37:55.941-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:55.941-0800: [GC concurrent-root-region-scan-end, 0.0001429 secs] 2020-10-28T17:37:55.941-0800: [GC concurrent-mark-start] 2020-10-28T17:37:55.942-0800: [GC concurrent-mark-end, 0.0012232 secs] 2020-10-28T17:37:55.942-0800: [GC remark, 0.0016931 secs] 2020-10-28T17:37:55.944-0800: [GC cleanup 322M->322M(512M), 0.0006263 secs] 2020-10-28T17:37:55.961-0800: [GC pause (G1 Evacuation Pause) (young) 422M->344M(512M), 0.0055068 secs] 2020-10-28T17:37:55.970-0800: [GC pause (G1 Evacuation Pause) (mixed) 360M->314M(512M), 0.0053395 secs] 2020-10-28T17:37:55.980-0800: [GC pause (G1 Evacuation Pause) (mixed) 341M->313M(512M), 0.0030762 secs] 2020-10-28T17:37:55.984-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 314M->313M(512M), 0.0021556 secs] 2020-10-28T17:37:55.986-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:55.986-0800: [GC concurrent-root-region-scan-end, 0.0001018 secs] 2020-10-28T17:37:55.986-0800: [GC concurrent-mark-start] 2020-10-28T17:37:55.987-0800: [GC concurrent-mark-end, 0.0010955 secs] 2020-10-28T17:37:55.987-0800: [GC remark, 0.0013116 secs] 2020-10-28T17:37:55.989-0800: [GC cleanup 320M->319M(512M), 0.0006829 secs] 2020-10-28T17:37:55.989-0800: [GC concurrent-cleanup-start] 2020-10-28T17:37:55.989-0800: [GC concurrent-cleanup-end, 0.0000176 secs] 2020-10-28T17:37:56.006-0800: [GC pause (G1 Evacuation Pause) (young) 420M->348M(512M), 0.0049978 secs] 2020-10-28T17:37:56.015-0800: [GC pause (G1 Evacuation Pause) (mixed) 364M->327M(512M), 0.0056048 secs] 2020-10-28T17:37:56.020-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 328M->328M(512M), 0.0013462 secs] 2020-10-28T17:37:56.022-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.022-0800: [GC concurrent-root-region-scan-end, 0.0001007 secs] 2020-10-28T17:37:56.022-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.023-0800: [GC concurrent-mark-end, 0.0010813 secs] 2020-10-28T17:37:56.023-0800: [GC remark, 0.0014307 secs] 2020-10-28T17:37:56.025-0800: [GC cleanup 334M->334M(512M), 0.0007524 secs] 2020-10-28T17:37:56.040-0800: [GC pause (G1 Evacuation Pause) (young) 415M->353M(512M), 0.0044198 secs] 2020-10-28T17:37:56.048-0800: [GC pause (G1 Evacuation Pause) (mixed) 371M->330M(512M), 0.0050846 secs] 2020-10-28T17:37:56.058-0800: [GC pause (G1 Evacuation Pause) (mixed) 361M->339M(512M), 0.0038992 secs] 2020-10-28T17:37:56.062-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 341M->340M(512M), 0.0020400 secs] 2020-10-28T17:37:56.064-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.064-0800: [GC concurrent-root-region-scan-end, 0.0001572 secs] 2020-10-28T17:37:56.065-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.066-0800: [GC concurrent-mark-end, 0.0015517 secs] 2020-10-28T17:37:56.066-0800: [GC remark, 0.0015832 secs] 2020-10-28T17:37:56.068-0800: [GC cleanup 349M->349M(512M), 0.0007675 secs] 2020-10-28T17:37:56.069-0800: [GC concurrent-cleanup-start] 2020-10-28T17:37:56.069-0800: [GC concurrent-cleanup-end, 0.0000178 secs] 2020-10-28T17:37:56.079-0800: [GC pause (G1 Evacuation Pause) (young) 402M->359M(512M), 0.0037371 secs] 2020-10-28T17:37:56.086-0800: [GC pause (G1 Evacuation Pause) (mixed) 380M->343M(512M), 0.0063242 secs] 2020-10-28T17:37:56.099-0800: [GC pause (G1 Evacuation Pause) (mixed) 374M->353M(512M), 0.0030269 secs] 2020-10-28T17:37:56.103-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 356M->354M(512M), 0.0014587 secs] 2020-10-28T17:37:56.104-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.105-0800: [GC concurrent-root-region-scan-end, 0.0001460 secs] 2020-10-28T17:37:56.105-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.106-0800: [GC concurrent-mark-end, 0.0012640 secs] 2020-10-28T17:37:56.106-0800: [GC remark, 0.0015092 secs] 2020-10-28T17:37:56.108-0800: [GC cleanup 364M->364M(512M), 0.0006737 secs] 2020-10-28T17:37:56.115-0800: [GC pause (G1 Evacuation Pause) (young) 398M->360M(512M), 0.0034289 secs] 2020-10-28T17:37:56.123-0800: [GC pause (G1 Evacuation Pause) (mixed) 381M->344M(512M), 0.0070435 secs] 2020-10-28T17:37:56.136-0800: [GC pause (G1 Evacuation Pause) (mixed) 369M->348M(512M), 0.0023993 secs] 2020-10-28T17:37:56.139-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 350M->347M(512M), 0.0013035 secs] 2020-10-28T17:37:56.140-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.140-0800: [GC concurrent-root-region-scan-end, 0.0001535 secs] 2020-10-28T17:37:56.140-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.142-0800: [GC concurrent-mark-end, 0.0012380 secs] 2020-10-28T17:37:56.142-0800: [GC remark, 0.0014225 secs] 2020-10-28T17:37:56.143-0800: [GC cleanup 354M->354M(512M), 0.0006083 secs] 2020-10-28T17:37:56.154-0800: [GC pause (G1 Evacuation Pause) (young) 409M->364M(512M), 0.0030872 secs] 2020-10-28T17:37:56.162-0800: [GC pause (G1 Evacuation Pause) (mixed) 389M->356M(512M), 0.0054986 secs] 2020-10-28T17:37:56.168-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 359M->356M(512M), 0.0016577 secs] 2020-10-28T17:37:56.170-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.170-0800: [GC concurrent-root-region-scan-end, 0.0001229 secs] 2020-10-28T17:37:56.170-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.171-0800: [GC concurrent-mark-end, 0.0012061 secs] 2020-10-28T17:37:56.171-0800: [GC remark, 0.0015987 secs] 2020-10-28T17:37:56.173-0800: [GC cleanup 365M->365M(512M), 0.0006106 secs] 2020-10-28T17:37:56.181-0800: [GC pause (G1 Evacuation Pause) (young) 402M->366M(512M), 0.0053228 secs] 2020-10-28T17:37:56.191-0800: [GC pause (G1 Evacuation Pause) (mixed) 393M->357M(512M), 0.0059182 secs] 2020-10-28T17:37:56.197-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 360M->357M(512M), 0.0012683 secs] 2020-10-28T17:37:56.198-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.199-0800: [GC concurrent-root-region-scan-end, 0.0001541 secs] 2020-10-28T17:37:56.199-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.200-0800: [GC concurrent-mark-end, 0.0013706 secs] 2020-10-28T17:37:56.200-0800: [GC remark, 0.0014036 secs] 2020-10-28T17:37:56.202-0800: [GC cleanup 368M->368M(512M), 0.0006670 secs] 2020-10-28T17:37:56.209-0800: [GC pause (G1 Evacuation Pause) (young) 401M->371M(512M), 0.0033649 secs] 2020-10-28T17:37:56.217-0800: [GC pause (G1 Evacuation Pause) (mixed) 396M->357M(512M), 0.0047377 secs] 2020-10-28T17:37:56.223-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 359M->356M(512M), 0.0012739 secs] 2020-10-28T17:37:56.224-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.224-0800: [GC concurrent-root-region-scan-end, 0.0000104 secs] 2020-10-28T17:37:56.224-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.225-0800: [GC concurrent-mark-end, 0.0012439 secs] 2020-10-28T17:37:56.225-0800: [GC remark, 0.0024532 secs] 2020-10-28T17:37:56.228-0800: [GC cleanup 365M->365M(512M), 0.0007465 secs] 2020-10-28T17:37:56.236-0800: [GC pause (G1 Evacuation Pause) (young) 406M->373M(512M), 0.0029663 secs] 2020-10-28T17:37:56.244-0800: [GC pause (G1 Evacuation Pause) (mixed) 398M->365M(512M), 0.0046893 secs] 2020-10-28T17:37:56.249-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 366M->366M(512M), 0.0027454 secs] 2020-10-28T17:37:56.251-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.251-0800: [GC concurrent-root-region-scan-end, 0.0000994 secs] 2020-10-28T17:37:56.252-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.253-0800: [GC concurrent-mark-end, 0.0015343 secs] 2020-10-28T17:37:56.253-0800: [GC remark, 0.0014862 secs] 2020-10-28T17:37:56.255-0800: [GC cleanup 373M->372M(512M), 0.0006620 secs] 2020-10-28T17:37:56.255-0800: [GC concurrent-cleanup-start] 2020-10-28T17:37:56.256-0800: [GC concurrent-cleanup-end, 0.0000176 secs] 2020-10-28T17:37:56.260-0800: [GC pause (G1 Evacuation Pause) (young) 394M->370M(512M), 0.0022404 secs] 2020-10-28T17:37:56.267-0800: [GC pause (G1 Evacuation Pause) (mixed) 397M->362M(512M), 0.0051909 secs] 2020-10-28T17:37:56.273-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 365M->362M(512M), 0.0023778 secs] 2020-10-28T17:37:56.275-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.275-0800: [GC concurrent-root-region-scan-end, 0.0001322 secs] 2020-10-28T17:37:56.276-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.277-0800: [GC concurrent-mark-end, 0.0011837 secs] 2020-10-28T17:37:56.277-0800: [GC remark, 0.0014813 secs] 2020-10-28T17:37:56.278-0800: [GC cleanup 372M->372M(512M), 0.0006447 secs] 2020-10-28T17:37:56.285-0800: [GC pause (G1 Evacuation Pause) (young) 398M->372M(512M), 0.0034519 secs] 2020-10-28T17:37:56.294-0800: [GC pause (G1 Evacuation Pause) (mixed) 401M->365M(512M), 0.0060335 secs] 2020-10-28T17:37:56.300-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 367M->365M(512M), 0.0013181 secs] 2020-10-28T17:37:56.302-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.302-0800: [GC concurrent-root-region-scan-end, 0.0001561 secs] 2020-10-28T17:37:56.302-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.303-0800: [GC concurrent-mark-end, 0.0011560 secs] 2020-10-28T17:37:56.303-0800: [GC remark, 0.0015121 secs] 2020-10-28T17:37:56.305-0800: [GC cleanup 372M->372M(512M), 0.0006388 secs] 2020-10-28T17:37:56.309-0800: [GC pause (G1 Evacuation Pause) (young) 393M->372M(512M), 0.0023350 secs] 2020-10-28T17:37:56.316-0800: [GC pause (G1 Evacuation Pause) (mixed) 394M->360M(512M), 0.0062292 secs] 2020-10-28T17:37:56.322-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 361M->361M(512M), 0.0013116 secs] 2020-10-28T17:37:56.324-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.324-0800: [GC concurrent-root-region-scan-end, 0.0000619 secs] 2020-10-28T17:37:56.324-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.325-0800: [GC concurrent-mark-end, 0.0012226 secs] 2020-10-28T17:37:56.325-0800: [GC remark, 0.0016248 secs] 2020-10-28T17:37:56.327-0800: [GC cleanup 368M->368M(512M), 0.0007924 secs] 2020-10-28T17:37:56.333-0800: [GC pause (G1 Evacuation Pause) (young) 399M->370M(512M), 0.0024200 secs] 2020-10-28T17:37:56.340-0800: [GC pause (G1 Evacuation Pause) (mixed) 394M->362M(512M), 0.0064275 secs] 2020-10-28T17:37:56.347-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 364M->362M(512M), 0.0018207 secs] 2020-10-28T17:37:56.349-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.349-0800: [GC concurrent-root-region-scan-end, 0.0001371 secs] 2020-10-28T17:37:56.349-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.351-0800: [GC concurrent-mark-end, 0.0014950 secs] 2020-10-28T17:37:56.351-0800: [GC remark, 0.0016386 secs] 2020-10-28T17:37:56.353-0800: [GC cleanup 368M->368M(512M), 0.0006985 secs] 2020-10-28T17:37:56.359-0800: [GC pause (G1 Evacuation Pause) (young) 399M->373M(512M), 0.0032093 secs] 2020-10-28T17:37:56.368-0800: [GC pause (G1 Evacuation Pause) (mixed) 397M->365M(512M), 0.0041457 secs] 2020-10-28T17:37:56.373-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 368M->365M(512M), 0.0028732 secs] 2020-10-28T17:37:56.376-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.376-0800: [GC concurrent-root-region-scan-end, 0.0001174 secs] 2020-10-28T17:37:56.376-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.377-0800: [GC concurrent-mark-end, 0.0012427 secs] 2020-10-28T17:37:56.377-0800: [GC remark, 0.0015740 secs] 2020-10-28T17:37:56.379-0800: [GC cleanup 374M->374M(512M), 0.0006373 secs] 2020-10-28T17:37:56.385-0800: [GC pause (G1 Evacuation Pause) (young) 404M->379M(512M), 0.0050623 secs] 2020-10-28T17:37:56.395-0800: [GC pause (G1 Evacuation Pause) (mixed) 405M->369M(512M), 0.0052086 secs] 2020-10-28T17:37:56.401-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 370M->369M(512M), 0.0023739 secs] 2020-10-28T17:37:56.403-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.404-0800: [GC concurrent-root-region-scan-end, 0.0001880 secs] 2020-10-28T17:37:56.404-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.405-0800: [GC concurrent-mark-end, 0.0012204 secs] 2020-10-28T17:37:56.405-0800: [GC remark, 0.0014976 secs] 2020-10-28T17:37:56.407-0800: [GC cleanup 379M->379M(512M), 0.0006870 secs] 2020-10-28T17:37:56.411-0800: [GC pause (G1 Evacuation Pause) (young) 402M->379M(512M), 0.0024589 secs] 2020-10-28T17:37:56.419-0800: [GC pause (G1 Evacuation Pause) (mixed) 408M->375M(512M), 0.0051110 secs] 2020-10-28T17:37:56.424-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 375M->375M(512M), 0.0029213 secs] 2020-10-28T17:37:56.427-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:37:56.427-0800: [GC concurrent-root-region-scan-end, 0.0000125 secs] 2020-10-28T17:37:56.427-0800: [GC concurrent-mark-start] 2020-10-28T17:37:56.428-0800: [GC concurrent-mark-end, 0.0012633 secs] 2020-10-28T17:37:56.428-0800: [GC remark, 0.0015612 secs] 2020-10-28T17:37:56.430-0800: [GC cleanup 383M->383M(512M), 0.0006570 secs] 2020-10-28T17:37:56.436-0800: [GC pause (G1 Evacuation Pause) (young) 409M->385M(512M), 0.0034377 secs] 执行结束! 共生成对象次数:9593 ``` ### 1G堆内存 G1 GC日志 ``` Learning_notes (main) ✗ java -XX:+UseG1GC -Xms1g -Xmx1g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:38:51.001-0800: [GC pause (G1 Evacuation Pause) (young) 72M->22M(1024M), 0.0062039 secs] 2020-10-28T17:38:51.018-0800: [GC pause (G1 Evacuation Pause) (young) 76M->38M(1024M), 0.0058841 secs] 2020-10-28T17:38:51.036-0800: [GC pause (G1 Evacuation Pause) (young) 91M->54M(1024M), 0.0063578 secs] 2020-10-28T17:38:51.063-0800: [GC pause (G1 Evacuation Pause) (young) 125M->83M(1024M), 0.0124005 secs] 2020-10-28T17:38:51.098-0800: [GC pause (G1 Evacuation Pause) (young) 164M->105M(1024M), 0.0092569 secs] 2020-10-28T17:38:51.131-0800: [GC pause (G1 Evacuation Pause) (young) 202M->136M(1024M), 0.0120010 secs] 2020-10-28T17:38:51.223-0800: [GC pause (G1 Evacuation Pause) (young) 340M->184M(1024M), 0.0228177 secs] 2020-10-28T17:38:51.281-0800: [GC pause (G1 Evacuation Pause) (young) 359M->232M(1024M), 0.0207753 secs] 2020-10-28T17:38:51.341-0800: [GC pause (G1 Evacuation Pause) (young) 438M->286M(1024M), 0.0181692 secs] 2020-10-28T17:38:51.543-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 770M->388M(1024M), 0.0437378 secs] 2020-10-28T17:38:51.587-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:38:51.587-0800: [GC concurrent-root-region-scan-end, 0.0002056 secs] 2020-10-28T17:38:51.587-0800: [GC concurrent-mark-start] 2020-10-28T17:38:51.590-0800: [GC concurrent-mark-end, 0.0025257 secs] 2020-10-28T17:38:51.590-0800: [GC remark, 0.0012450 secs] 2020-10-28T17:38:51.591-0800: [GC cleanup 407M->400M(1024M), 0.0008244 secs] 2020-10-28T17:38:51.592-0800: [GC concurrent-cleanup-start] 2020-10-28T17:38:51.592-0800: [GC concurrent-cleanup-end, 0.0000206 secs] 2020-10-28T17:38:51.606-0800: [GC pause (G1 Evacuation Pause) (young) 484M->406M(1024M), 0.0116056 secs] 2020-10-28T17:38:51.625-0800: [GC pause (G1 Evacuation Pause) (mixed) 447M->350M(1024M), 0.0080566 secs] 2020-10-28T17:38:51.668-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 563M->406M(1024M), 0.0064617 secs] 2020-10-28T17:38:51.674-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:38:51.674-0800: [GC concurrent-root-region-scan-end, 0.0002256 secs] 2020-10-28T17:38:51.674-0800: [GC concurrent-mark-start] 2020-10-28T17:38:51.676-0800: [GC concurrent-mark-end, 0.0011113 secs] 2020-10-28T17:38:51.676-0800: [GC remark, 0.0014484 secs] 2020-10-28T17:38:51.677-0800: [GC cleanup 415M->410M(1024M), 0.0009806 secs] 2020-10-28T17:38:51.678-0800: [GC concurrent-cleanup-start] 2020-10-28T17:38:51.678-0800: [GC concurrent-cleanup-end, 0.0000200 secs] 2020-10-28T17:38:51.764-0800: [GC pause (G1 Evacuation Pause) (young)-- 839M->633M(1024M), 0.0093063 secs] 2020-10-28T17:38:51.775-0800: [GC pause (G1 Evacuation Pause) (mixed) 639M->577M(1024M), 0.0097171 secs] 2020-10-28T17:38:51.785-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 581M->579M(1024M), 0.0017935 secs] 2020-10-28T17:38:51.787-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:38:51.787-0800: [GC concurrent-root-region-scan-end, 0.0001397 secs] 2020-10-28T17:38:51.787-0800: [GC concurrent-mark-start] 2020-10-28T17:38:51.789-0800: [GC concurrent-mark-end, 0.0013635 secs] 2020-10-28T17:38:51.789-0800: [GC remark, 0.0015240 secs] 2020-10-28T17:38:51.791-0800: [GC cleanup 589M->582M(1024M), 0.0009617 secs] 2020-10-28T17:38:51.792-0800: [GC concurrent-cleanup-start] 2020-10-28T17:38:51.792-0800: [GC concurrent-cleanup-end, 0.0000164 secs] 2020-10-28T17:38:51.837-0800: [GC pause (G1 Evacuation Pause) (young) 845M->629M(1024M), 0.0096547 secs] 2020-10-28T17:38:51.852-0800: [GC pause (G1 Evacuation Pause) (mixed) 657M->537M(1024M), 0.0054220 secs] 2020-10-28T17:38:51.867-0800: [GC pause (G1 Evacuation Pause) (mixed) 593M->471M(1024M), 0.0055333 secs] 2020-10-28T17:38:51.885-0800: [GC pause (G1 Evacuation Pause) (mixed) 533M->448M(1024M), 0.0048173 secs] 2020-10-28T17:38:51.893-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark) 462M->452M(1024M), 0.0021663 secs] 2020-10-28T17:38:51.895-0800: [GC concurrent-root-region-scan-start] 2020-10-28T17:38:51.895-0800: [GC concurrent-root-region-scan-end, 0.0001342 secs] 2020-10-28T17:38:51.895-0800: [GC concurrent-mark-start] 2020-10-28T17:38:51.897-0800: [GC concurrent-mark-end, 0.0012777 secs] 2020-10-28T17:38:51.897-0800: [GC remark, 0.0023995 secs] 2020-10-28T17:38:51.899-0800: [GC cleanup 459M->453M(1024M), 0.0009393 secs] 2020-10-28T17:38:51.900-0800: [GC concurrent-cleanup-start] 2020-10-28T17:38:51.900-0800: [GC concurrent-cleanup-end, 0.0000270 secs] 执行结束! 共生成对象次数:11061 ``` ### 2G堆内存 G1 GC日志 ``` Learning_notes (main) ✗ java -XX:+UseG1GC -Xms2g -Xmx2g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:39:15.189-0800: [GC pause (G1 Evacuation Pause) (young) 121M->36M(2048M), 0.0122631 secs] 2020-10-28T17:39:15.228-0800: [GC pause (G1 Evacuation Pause) (young) 142M->68M(2048M), 0.0113469 secs] 2020-10-28T17:39:15.265-0800: [GC pause (G1 Evacuation Pause) (young) 173M->105M(2048M), 0.0119550 secs] 2020-10-28T17:39:15.308-0800: [GC pause (G1 Evacuation Pause) (young) 220M->140M(2048M), 0.0116792 secs] 2020-10-28T17:39:15.343-0800: [GC pause (G1 Evacuation Pause) (young) 258M->174M(2048M), 0.0124379 secs] 2020-10-28T17:39:15.406-0800: [GC pause (G1 Evacuation Pause) (young) 349M->229M(2048M), 0.0184841 secs] 2020-10-28T17:39:15.710-0800: [GC pause (G1 Evacuation Pause) (young) 875M->370M(2048M), 0.0528112 secs] 2020-10-28T17:39:15.770-0800: [GC pause (G1 Evacuation Pause) (young) 414M->378M(2048M), 0.0089638 secs] 2020-10-28T17:39:15.843-0800: [GC pause (G1 Evacuation Pause) (young) 718M->453M(2048M), 0.0213807 secs] 2020-10-28T17:39:15.923-0800: [GC pause (G1 Evacuation Pause) (young) 779M->518M(2048M), 0.0302269 secs] 2020-10-28T17:39:16.023-0800: [GC pause (G1 Evacuation Pause) (young) 893M->599M(2048M), 0.0295562 secs] 执行结束! 共生成对象次数:10186 ``` ### 4G堆内存 G1 GC日志 ``` Learning_notes (main) ✗ java -XX:+UseG1GC -Xms4g -Xmx4g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:39:44.171-0800: [GC pause (G1 Evacuation Pause) (young) 204M->61M(4096M), 0.0268331 secs] 2020-10-28T17:39:44.235-0800: [GC pause (G1 Evacuation Pause) (young) 239M->110M(4096M), 0.0230679 secs] 2020-10-28T17:39:44.289-0800: [GC pause (G1 Evacuation Pause) (young) 288M->163M(4096M), 0.0252689 secs] 2020-10-28T17:39:44.344-0800: [GC pause (G1 Evacuation Pause) (young) 341M->213M(4096M), 0.0237294 secs] 2020-10-28T17:39:44.401-0800: [GC pause (G1 Evacuation Pause) (young) 391M->269M(4096M), 0.0285358 secs] 2020-10-28T17:39:44.460-0800: [GC pause (G1 Evacuation Pause) (young) 447M->326M(4096M), 0.0247653 secs] 2020-10-28T17:39:44.510-0800: [GC pause (G1 Evacuation Pause) (young) 504M->386M(4096M), 0.0255301 secs] 2020-10-28T17:39:44.565-0800: [GC pause (G1 Evacuation Pause) (young) 574M->449M(4096M), 0.0292658 secs] 2020-10-28T17:39:44.632-0800: [GC pause (G1 Evacuation Pause) (young) 671M->514M(4096M), 0.0312543 secs] 2020-10-28T17:39:44.726-0800: [GC pause (G1 Evacuation Pause) (young) 796M->593M(4096M), 0.0403226 secs] 执行结束! 共生成对象次数:9752 ``` ### 8G堆内存 G1 GC日志 ``` ➜ Learning_notes (main) ✗ java -XX:+UseG1GC -Xms8g -Xmx8g -XX:+PrintGC -XX:+PrintGCDateStamps GCLogAnalysis 正在执行 2020-10-28T17:41:19.752-0800: [GC pause (G1 Evacuation Pause) (young) 408M->121M(8192M), 0.0474560 secs] 2020-10-28T17:41:19.855-0800: [GC pause (G1 Evacuation Pause) (young) 477M->215M(8192M), 0.0389705 secs] 2020-10-28T17:41:19.948-0800: [GC pause (G1 Evacuation Pause) (young) 571M->301M(8192M), 0.0373245 secs] 2020-10-28T17:41:20.036-0800: [GC pause (G1 Evacuation Pause) (young) 657M->400M(8192M), 0.0423555 secs] 2020-10-28T17:41:20.127-0800: [GC pause (G1 Evacuation Pause) (young) 756M->493M(8192M), 0.0405221 secs] 2020-10-28T17:41:20.220-0800: [GC pause (G1 Evacuation Pause) (young) 849M->593M(8192M), 0.0429381 secs] 2020-10-28T17:41:20.313-0800: [GC pause (G1 Evacuation Pause) (young) 949M->699M(8192M), 0.0472177 secs] 2020-10-28T17:41:20.415-0800: [GC pause (G1 Evacuation Pause) (young) 1055M->798M(8192M), 0.0505110 secs] 执行结束! 共生成对象次数:12143 ``` ### 我的测试机子 MacBook Pro (15-inch, Late 2016) cpu : 2.7 GHz 四核Intel Core i7 内存:16g ##统计结果 | 内存 | 串行GC | 并行GC | CMS GC | G1 GC | | -------- | ----------------------------------- | ---------------------------- | ----------------------------------------- | -------------------------------------- | | **256m** | 9次YGC 17次FULL GC /生成对象4334 | OOM | 17次YGC 2次FULL GC /10次CMS /生成对象4219 | OOM | | 512m | 14次YGC 0次FULL GC /生成对象 7336 | 26次YGC 8次FULL GC /生成对象 | 23次YGC 0次FULL GC /25次CMS/生成对象10046 | 200+次以上YGC 0次FULL GC /生成对象9593 | | 1g | 9次YGC 0次FULL GC /生成对象 9403 | 13次YGC 3次FULL GC /生成对象 | 14次YGC 0次FULL GC /15次cms/生成对象11698 | 53次YGC 0次FULL GC /生成对象11061 | | 2g | 5次YGC 0次FULL GC /生成对象 10520 | 5次YGC 0次FULL GC /生成对象 | 4次YGC 0次FULL GC /生成对象10173 | 10次YGC 0次FULL GC /生成对象10186 | | 4g | 2次YGC 0次FULL GC /生成对象8428 | 2次YGC 0次FULL GC /生成对象 | 5次YGC 0次FULL GC /生成对象10215 | 10次YGC 0次FULL GC /生成对象9752 | | 8g | 0次YGC 0次FULL GC /生成对象 6357 | 0次YGC 0次FULL GC /生成对象 | 5次YGC 0次FULL GC /生成对象10318 | 8次YGC 0次FULL GC /生成对象12143 | ### 结果分析 **四种GC算法的共同点:** 在内存为256M时候,内存不够使用,不论怎么回收,老年代都会堆满活动对象无法回收,四种GC算法都无法处理这样的场景,最后都会导致OOM,在内存足够用时候,内存8g以上,老年代不会出现内存不够用的情况,四种GC算法都不需要进行full gc, 也不是内存越高越好,和机子的性能也有关系 ,对于同一种GC而言,堆内存空间越大,触发GC的次数就越少,相对地业务线程的执行时间会变多,吞吐量也就会提升 **四种GC算法的不同点:** 在堆内存比较小时候,四种GC的频次都比较高,在这样场景下每次GC中存活的对象都是很少的,多线程并行处理并不能发挥出优势来,反而会有多线程竞争,造成时间浪费,此时串行GC下的吞吐率反而高于并行GC的吞吐率,但是堆内存比较充足的情况下,gc次数减少,每次GC的存活对象相对多一些时候,并行多线程就会发挥出优势,从统计结果中可以看出内存量比较充足时候,并行GC下的吞吐量是最大的,串行GC的吞吐量是最低的,CMS GC 的实现中GC和业务线程是并发执行的,目的是减少延迟,回收效率相比并行GC要低一些,吞吐量相对并行GC而言同样会低一些,同样的,G1 GC并不是每一次GC都把所有垃圾对象清理掉,回收效率相对并行GC而言低一些,总的吞吐率也相对低一些,并且由于是启发式的GC算法,所以造成吞吐率浮动比较大,表现出来的垃圾回收效率没有其他几种GC稳定 ## 作业五     写一段代码,使用 HttpClient 或 OkHttp 访问[http://localhost:8801,代码提交到](http://localhost:8801,代码提交到/) github 先运行 [HttpServer01.java](https://github.com/edd1225/JAVA-000/blob/main/Week_01/Java_training_code/src/main/java/cn/qj/week2/HttpServer01.java) ```java package cn.qj.week2; import java.io.IOException; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; /** * */ public class HttpServer01 { public static void main(String[] args) throws IOException{ ServerSocket serverSocket = new ServerSocket(8801); while (true) { try { Socket socket = serverSocket.accept(); service(socket); } catch (IOException e) { e.printStackTrace(); } } } private static void service(Socket socket) { try { Thread.sleep(20); PrintWriter printWriter = new PrintWriter(socket.getOutputStream(), true); printWriter.println("HTTP/1.1 200 OK"); printWriter.println("Content-Type:text/html;charset=utf-8"); printWriter.println(); printWriter.write("hello,nio"); printWriter.close(); socket.close(); } catch (IOException | InterruptedException e) { e.printStackTrace(); } } } ```     这里使用OKHttp     需要添加下面两个Maven依赖: ```shell <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.9.0</version> </dependency> ```     代码如下: ```java package cn.qj.week2; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import java.io.IOException; /* Copyright @ 2019 Citycloud Co. Ltd. * All right reserved. * OkHttpDemo * * @author edd1225 * @Description: OkHttpDemo * @create 2020/10/28 12:23 **/ public class OkHttpDemo { public static void main(String[] args) throws IOException { OkHttpClient client = new OkHttpClient(); try { Request request = new Request.Builder().url("http://127.0.0.1:8801/test").build(); Response response = client.newCall(request).execute(); System.out.println(response.body().string()); } finally { client.clone(); } } } ```     返回结果: ``` hello,nio ```
Python
UTF-8
601
3.546875
4
[]
no_license
# Create functions to represent all basic math operations on 2 arguments in sequence. def add(a,b): return a + b def multiply(a,b): return a * b def divide(a,b): return a / b def mod(a,b): return a % b def exponent(a,b): return a ** b def subt(a,b): return a - b # As lamba functions. add2 = lambda a, b: a + b multiply2 = lambda a, b: a * b divide2 = lambda a, b: a / b mod2 = lambda a, b: a % b exponent2 = lambda a, b: a ** b subt2 = lambda a, b:a - b # From built in operator module from operator import add as add3, mul as multiply3, div as divide3, mod as mod3, pow as exponent3, sub as subt3
Shell
UTF-8
1,847
2.984375
3
[ "Apache-2.0" ]
permissive
#!/bin/bash set -e [[ $DEBUG ]] && set -x . /opt/kolla/kolla-common.sh . /opt/kolla/config-glance.sh : ${GLANCE_API_SERVICE_HOST:=$PUBLIC_IP} check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ OS_USERNAME OS_PASSWORD \ GLANCE_KEYSTONE_USER GLANCE_KEYSTONE_PASSWORD \ ADMIN_TENANT_NAME GLANCE_API_SERVICE_HOST \ PUBLIC_IP GLANCE_REGISTRY_SERVICE_HOST REGION_NAME fail_unless_os_service_running keystone . /opt/kolla/crux.sh export OS_PROJECT_DOMAIN_NAME=Default export OS_PROJECT_NAME=admin export OS_AUTH_URL=http://$KEYSTONE_MASTER_PORT_35357_TCP_ADDR:5000/v3 export OS_IDENTITY_API_VERSION=3 env | grep OS_ crux_user ${GLANCE_KEYSTONE_PASSWORD} ${GLANCE_KEYSTONE_USER} crux_role_add service $GLANCE_KEYSTONE_USER admin crux_service glance image "OpenStack Image" crux_endpoint $REGION_NAME image public http://$GLANCE_API_SERVICE_HOST:9292 crux_endpoint $REGION_NAME image internal http://$GLANCE_API_SERVICE_HOST:9292 crux_endpoint $REGION_NAME image admin http://$GLANCE_API_SERVICE_HOST:9292 crudini --set /etc/glance/glance-api.conf \ DEFAULT \ registry_host \ "${GLANCE_REGISTRY_SERVICE_HOST}" crudini --set /etc/glance/glance-api-paste.ini \ "filter:authtoken" \ identity_uri \ "http://$KEYSTONE_PORT_35357_TCP_ADDR:35357" crudini --set /etc/glance/glance-api-paste.ini \ "filter:authtoken" \ admin_user \ $GLANCE_KEYSTONE_USER crudini --set /etc/glance/glance-api-paste.ini \ "filter:authtoken" \ admin_password \ $GLANCE_KEYSTONE_PASSWORD crudini --set /etc/glance/glance-api-paste.ini \ "filter:authtoken" \ admin_tenant_name \ service echo "Starting glance-api" glance-api --version if [ -z $DEBUG ]; then exec glance-api -v else exec glance-api -dv fi
Java
UTF-8
3,876
1.898438
2
[]
no_license
package com.lxh.flashari.ui.originalImg; import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.os.RemoteException; import android.util.Log; import com.lxh.flashari.api.ApiManager; import com.lxh.flashari.common.BaseCallback; import com.lxh.flashari.common.base.BaseMvpPresenter; import com.lxh.flashari.common.config.Config; import com.lxh.flashari.model.UploadModel; import com.lxh.flashari.model.UploadModelImpl; import com.lxh.flashari.service.AidiCallback; import com.lxh.flashari.utils.AidlUtils; import com.lxh.flashari.utils.ConvertUtils; import com.lxh.processmodule.IOperateWifiAidl; import com.qiniu.android.storage.UpProgressHandler; import com.qiniu.android.storage.UploadOptions; import java.util.HashMap; public class OriginalImgPresenter extends BaseMvpPresenter<OriginalImgView> { private UploadModel mUploadModel; private Bitmap mBitmap; public OriginalImgPresenter() { mUploadModel = UploadModelImpl.getInstance(); } public void upload(String fileName) { if (mBitmap == null) { getView().showToast("么有获取图片"); return; } byte[] picturePath = ConvertUtils.bitmap2Bytes(mBitmap, Bitmap.CompressFormat.JPEG); HashMap<String, String> map = new HashMap<>(); map.put("x:phone", "12345678"); Log.d("qiniu", "click upload"); mUploadModel.uploadBytes(fileName, picturePath, (key, info, response) -> { }, new UploadOptions(map, null, false, new UpProgressHandler() { @Override public void progress(String key, double percent) { Log.i("qiniu", key + ": " + percent); // progressbar.setVisibility(View.VISIBLE); // int progress = (int)(percent*1000); //// Log.d("qiniu", progress+""); // progressbar.setProgress(progress); // if(progress==1000){ // progressbar.setVisibility(View.GONE); // } } }, null)); } public void downloadFile(String downloadFile, String directory) { // Download file String url = ApiManager.BASE_WIFI_PATH + "/" + directory + "/" + downloadFile; AidlUtils.useOperateWifiAidl((Context) getView(), new AidiCallback<IOperateWifiAidl>() { @Override public void onSucceed(IOperateWifiAidl iOperateWifiAidl) { try { iOperateWifiAidl.getOriginalImage(url, new BaseCallback() { @Override public void onSucceed(Bundle bundle) { if (bundle != null) { int progress = bundle.getInt(Config.KeyCode.KEY_ORIGINAL_PROGRESS); getView().setNumProgress(progress); if (bundle.containsKey(Config.KeyCode.KEY_ORIGINAL_IMAGE)) { mBitmap = bundle.getParcelable(Config.KeyCode.KEY_ORIGINAL_IMAGE); if (mBitmap != null) { getView().setOriginalImg(mBitmap); } } } } @Override public void onFailed(String bundle) { } }); } catch (RemoteException e) { getView().showToast(e.getMessage()); e.printStackTrace(); } finally { } } @Override public void onFailed(Throwable throwable) { } }); } }
Markdown
UTF-8
2,093
3.078125
3
[ "MIT" ]
permissive
# month [![NPM version](https://badge.fury.io/js/month.svg)](http://badge.fury.io/js/month) > Get the name or number of the current month or any month of the year. Install with [npm](https://www.npmjs.com/) ```sh $ npm i month --save ``` ## Usage ```js var month = require('month'); month(); //=> 'January' (current month full name) month('M'); //=> '1' (current month number) month('MM'); //=> '01' (current month number, zero-filled) month('MMM'); //=> 'Jan' (current month abbreviation) month('MMMM'); //=> 'January' (current month full name) month('January'); //=> '12' (number of the given month number) month(1); //=> 'January' (name of the given month number) month(2); //=> 'February' ``` ## Related projects * [days](https://github.com/jonschlinkert/days): Days of the week. * [iso-week](https://github.com/jonschlinkert/iso-week): Get the ISO week of the year. * [months](https://github.com/jonschlinkert/months): Months of the year. * [o-clock](https://github.com/jonschlinkert/o-clock): Simple utility for displaying the time in 12-hour clock format. * [seconds](https://github.com/jonschlinkert/seconds): Get the number of seconds for a minute, hour, day and week. * [weekday](https://github.com/jonschlinkert/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/jonschlinkert/weekday) * [week](https://github.com/jonschlinkert/week): Get the current week number. * [year](https://github.com/jonschlinkert/year): Simple utility to get the current year with 2 or 4 digits. ## Running tests Install dev dependencies: ```sh $ npm i -d && npm test ``` ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/datetime/month/issues/new) ## Author **Jon Schlinkert** + [github/datetime](https://github.com/datetime) + [twitter/datetime](http://twitter.com/datetime) ## License Copyright © 2015 Jon Schlinkert Released under the MIT license. *** _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 25, 2015._
Ruby
UTF-8
1,652
2.8125
3
[]
no_license
module ModelIntegrityCheck class ModelCheck def compute_values! return if @computed @klass.find_each do |instance| @total_count += 1 next if instance.valid? @errors_count += 1 instance.errors.full_messages.each do |message| @errors_hash[message] ||= 0 @errors_hash[message] += 1 end end @computed = true end def errors_to_s @errors_hash.sort_by { |name, count| count }.map { |pair| "#{ pair[1] } => #{ pair[0] }"}.join("\n ") end def initialize(klass) @klass = klass @errors_hash = {} @errors_count = 0 @total_count = 0 @computed = false end def to_s self.compute_values! """#{ @klass.name } Total: #{ @total_count } Invalid: #{ @errors_count } Invalid Reasons: #{ @errors_count > 0 ? self.errors_to_s : 'None' } """ end def self.model_names Dir["#{Rails.root}/app/models/**/*.rb"].map do |full_path| full_path.gsub('.rb', '').gsub(/.*\/app\/models\//, '').camelize end end def self.models ModelCheck.model_names.map { |name| Object.const_get(name) } end def self.active_record_models ModelCheck.models.select { |model| model < ActiveRecord::Base } end def self.model_checks(only_these = []) these_models = ModelCheck.active_record_models if only_these.length > 0 these_models.select! { |model| only_these.include?(model.name.downcase) } end these_models.map { |model| ModelCheck.new(model) } end end end
Java
UTF-8
1,925
3
3
[]
no_license
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package cos; /** * Klasa zawierająca informacje o podstawowych parametrach gry. * * @author Piotr Kierzek i Michał Janczyk */ public class GameInfo { // deklarujemy zmienne informujące o informacjach dotyczących gry static int difficulty; static int lives; static int gamelength; static int numberofdeaths; static int bonus; static int penaltyfordeath; static int points; static int levels; /** * Metoda nadająca wartości zaimportowane przez metodę {@link cos.importConfig#importConfig() } podstawowym parametrom aplikacji. * @param values Wektor (w formie tablicy 1-wymiarowej int[]) zawierający podstawowe dane o grze, w kolejności: <br> * difficulty - poziom trudności gry (0 - łatwe, 1 - średnie, 2 - trudne); <br> * lives - startowa liczba żyć; <br> * gamelength - początkowa wartość czasu dla gry; <br> * numberofdeaths - początkowa liczba śmierci; <br> * bonus - wielkość bonusu czasowego, który może zostać uzyskany przez gracza; <br> * penaltyfordeath - czas doliczany za każdą śmierc; <br> * points - początkowa liczba punktów; punkty liczone są na zasadzie czas+(l.śmierci*kara)-(l.bonusów*bonus); <br> * levels - liczba poziomów w grze, po których następuje wymuszony koniec gry. */ public static void setInit(int[] values){ // metoda inicjalizująca zmienne tak jak pan config przykazał difficulty = values[0]; lives = values[1]; gamelength = values[2]; numberofdeaths = values[3]; bonus = values[4]; penaltyfordeath = values[5]; points = values[6]; levels = values[7]; } }
Python
UTF-8
3,366
3.109375
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- import os import sys class Location(object): def __init__(self, path, module, function, line, character, absolute_path=True): if sys.version_info.major == 2 and isinstance(path, str): # If this is not a unicode object, make it one! Some tools return # paths as unicode, some as bytestring, so to ensure that they are # all the same, we normalise here. For Python3 this is (probably) # always a str so no need to do anything. path = path.decode(sys.getfilesystemencoding()) self.path = path self._path_is_absolute = absolute_path self.module = module or None self.function = function or None self.line = None if line == -1 else line self.character = None if character == -1 else character def to_absolute_path(self, root): if self._path_is_absolute: return self.path = os.path.abspath(os.path.join(root, self.path)) self._path_is_absolute = True def to_relative_path(self, root): if not self._path_is_absolute: return self.path = os.path.relpath(self.path, root) self._path_is_absolute = False def as_dict(self): return { 'path': self.path, 'module': self.module, 'function': self.function, 'line': self.line, 'character': self.character } def __hash__(self): return hash((self.path, self.line, self.character)) def __eq__(self, other): return self.path == other.path and self.line == other.line and self.character == other.character def __lt__(self, other): if self.path == other.path: if self.line == other.line: return (self.character or -1) < (other.character or -1) return (self.line or -1) < (other.line or -1) # line can be None if it a file-global warning return self.path < other.path class Message(object): def __init__(self, source, code, location, message): self.source = source self.code = code self.location = location self.message = message def to_absolute_path(self, root): self.location.to_absolute_path(root) def to_relative_path(self, root): self.location.to_relative_path(root) def as_dict(self): return { 'source': self.source, 'code': self.code, 'location': self.location.as_dict(), 'message': self.message } def __repr__(self): return "%s-%s" % (self.source, self.code) def __eq__(self, other): if self.location == other.location: return self.code == other.code else: return False def __lt__(self, other): if self.location == other.location: return self.code < other.code return self.location < other.location def make_tool_error_message(filepath, source, code, message, line=0, character=0, module=None, function=None): location = Location( path=filepath, module=module, function=function, line=line, character=character ) return Message( source=source, code=code, location=location, message=message )
Shell
UTF-8
13,527
3.21875
3
[ "Apache-2.0" ]
permissive
#!/bin/bash -e PATH=/usr/bin:/bin:/usr/local/bin:/usr/local/rvm/gems/ruby-2.0.0-p247/bin: set -x export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=512m" function copy_to_repo { WWW="/data/packages/" find . -name *.deb | while read f; do if [ -e ${f} ]; then cp -r ${f} $WWW/ fi # backup the file done } function pre-packaging { # Backend mkdir -p cloudpass/backend cloudpass/frontend/idm-cloudpass/target mv backend/build cloudpass/backend # Frontend mv frontend/idm-cloudpass/target/cloudpass-0.1.war cloudpass/frontend/idm-cloudpass/target/ } function enable_search { find . -name search.yml | while read f; do # first enable everything, and change data folder from /tmp/.. to /data/.. if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the original file cp $f ${f}.local sed 's/enabled: false/enabled: true/g' $f > $f.0 sed 's/\/tmp\//\/data\//g' $f.0 > ${f}.1 # the enabled flag in inputConfiguration section should be disabled sed -e '1,/^inputConfiguration/b' -e 's/enabled: true/enabled: false/g' ${f}.1 > ${f}.2 # after timeLineConfiguration, enable again sed -e '1,/^timeLineConfiguration/b' -e 's/enabled: false/enabled: true/g' ${f}.2 > ${f}.3 # everything after hornetQServerConfiguration should be disabled sed -e '1,/^hornetQServerConfiguration/b' -e 's/enabled: true/enabled: false/g' ${f}.3 > ${f}.4 sed -e '27 s|"com.totvslabs.idm.service.search.analyzer.LowerCaseEnglishKeywordAnalyzer"|"com.totvslabs.idm.service.search.analyzer.LowerCaseWhiteSpacePorterStemAnalyzer"|g' ${f}.4 > ${f}.5 sed -e '70 s|"com.totvslabs.idm.service.search.analyzer.LowerCaseEnglishKeywordAnalyzer"|"com.totvslabs.idm.service.search.analyzer.LowerCaseWhiteSpacePorterStemAnalyzer"|g' ${f}.5 > ${f}.6 sed -e 's|\/data\/logs\/|\/data\/fluigidentity-logs\/|' ${f}.6 > ${f}.7 sed -e 's|\/tmp\/logs\/|\/data\/fluigidentity-logs\/|' ${f}.7 > ${f}.8 sed -e '653 s|enabled: false|enabled: true|g' ${f}.8 > ${f}.9 sed -e 's|reindex: true|reindex: false|g' ${f}.9 > ${f}.10 sed 's/providerUrl.*/providerUrl: "jnp:\/\/172\.20\.16\.16:2099"/' ${f}.10 > ${f}.11 mv ${f}.11 ${f} rm $f.0 ${f}.1 ${f}.2 ${f}.3 ${f}.4 ${f}.5 ${f}.6 ${f}.7 ${f}.8 ${f}.9 ${f}.10 cp $f ${f}.local done } function enable_aws { find . -name aws.yml | while read f; do # if there is a backup file, restore it if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the original file cp $f ${f}.local sed 's/ttl:.*/ttl: 60/g' $f > ${f}.1 sed 's/enabled: false/enabled: true/g' ${f}.1 > $f /bin/rm ${f}.1 cp ${f} $f.local done } function productionize_server_properties { find . -name server.properties | while read f; do # if backup file already exist, restore it if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/couchbaseServerUrls=.*/couchbaseServerUrls=172\.21\.16\.11:8091;172\.21\.16\.12:8091;/' $f > ${f}.1 sed 's/couchbaseAdminPwd=.*/couchbaseAdminPwd=ZktwGaEhqbsAJHlAqiQP/' ${f}.1 > ${f}.2 sed 's/cloudpassBucketPwd=.*/cloudpassBucketPwd=Lp6656MC461rn0V/' ${f}.2 > ${f}.3 sed 's/keyStoreServer=.*/keyStoreServer=172\.20\.16\.14/' ${f}.3 > ${f}.4 ## Replace SearchURL sed 's/searchUrl=.*/searchUrl\=http\:\/\/172.20.16.16\:18084\/search/' ${f}.4 > ${f}.5 sed 's/email_admin_name=.*/email_admin_name=support@fluigidentity.com/g' ${f}.5 > ${f}.6 sed 's/email_admin_password=.*/email_admin_password=s\[78Q4-52331FE)/g' ${f}.6 > ${f}.7 sed 's/smtp_host=.*/smtp_host=mail\.fluigidentity\.com/g' ${f}.7 > ${f}.8 sed 's/remoteCallsEnabled=false/remoteCallsEnabled=true/g' ${f}.8 > ${f}.9 mv ${f}.9 $f rm ${f}.1 ${f}.2 ${f}.3 ${f}.4 ${f}.5 ${f}.6 ${f}.7 ${f}.8 cp ${f} $f.local done } function productionize_keystore_properties { find . -name keystore.server.properties | while read f; do # if backup file already exist, restore it if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp ${f} ${f}.local sed 's/keyStorePassword=totvslabs/keyStorePassword=M\@5\}i\%\>\<\!28\&3\)v/g' ${f} > ${f}.1 mv ${f}.1 ${f} cp ${f} $f.local done } function productionize_keystore_yml { find . -name keystore.yml | while read f; do # if backup file already exist, restore it if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/listenAddress:.*/listenAddress: "172.20.16.14"/' ${f} > ${f}.1 sed 's/address: \"127.0.0.1\"/address: \"172.20.16.14\"/g' $f.1 > ${f}.2 sed 's/address: \"localhost\"/address: \"172.20.16.14\"/g' $f.2 > ${f}.3 sed 's/remote: \"127.0.0.1\"/remote: \"172.20.16.20\"/g' $f.3 > ${f}.4 sed 's/keyStorePassword: \"totvslabs\"/keyStorePassword: \"M@5}i%><!28\&3)v"/g' ${f}.4 > ${f}.5 sed -e 's|\/data\/logs\/|\/data\/fluigidentity-logs\/|' ${f}.5 > ${f}.6 sed -e 's|\/tmp\/logs\/|\/data\/fluigidentity-logs\/|' ${f}.6 > ${f}.7 sed -e '89 s/false/true/g' ${f}.7 > ${f}.8 mv ${f}.8 ${f} rm -rf ${f}.1 ${f}.2 ${f}.3 ${f}.4 ${f}.5 ${f}.6 ${f}.7 cp $f ${f}.local done } function productionize_rest_yml { find . -name rest.yml| while read f; do # if backup file already exist, restore it if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/prodEnvironment\: false/prodEnvironment\: true/' ${f} > ${f}.0 sed 's/fluigIdentityServerUrl:.*/fluigIdentityServerUrl: https\:\/\/app\.fluigidentity\.com/' ${f}.0 > ${f}.1 sed 's/providerUrl.*/providerUrl: "jnp:\/\/172\.20\.16\.16:2099"/' ${f}.1 > ${f}.2 sed -e '229 s/false/true/' ${f}.2 > ${f}.3 sed 's/listenAddress:.*/listenAddress: "172\.20\.16\.16"/g' ${f}.3 > ${f}.4 sed -e 's|\/data\/logs\/|\/data\/fluigidentity-logs\/|' ${f}.4 > ${f}.5 sed -e '255 s/false/true/g' ${f}.5 > ${f}.6 mv ${f}.6 $f rm -rf ${f}.0 ${f}.1 ${f}.2 ${f}.3 ${f}.4 ${f}.5 cp $f ${f}.local done } function productionize_hornetq { find . -name hornetq.jndi.properties | while read f; do # if backup file already exist, restore it if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/java\.naming\.provider\.url=.*/java\.naming\.provider\.url=jnp:\/\/172\.20\.16\.16:2099/' $f > ${f}.1 mv ${f}.1 ${f} cp ${f} $f.local done } function productionize_adsync { find . -name adsync.yml | while read f; do if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/providerUrl:.*/providerUrl: jnp:\/\/172\.20\.16\.16:2099/' $f > ${f}.1 sed -e 's|\/tmp\/logs\/|/data\/fluigidentity-logs\/|' ${f}.1 > ${f}.2 sed -e 's|\/data\/logs\/|/data\/fluigidentity-logs\/|' ${f}.2 > ${f}.3 sed -e '292 s/false/true/g' ${f}.3 > ${f}.4 mv ${f}.4 ${f} rm -rf ${f}.1 ${f}.2 ${f}.3 cp ${f} ${f}.local done } function productionize_backend_rmi { find . -name rmi.server.properties | while read f; do if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp -rf $f ${f}.local sed 's/hostname=.*/hostname=172\.20\.16\.12/' ${f} > ${f}.1 mv ${f}.1 ${f} cp ${f} ${f}.local done } function productionize_backend_scim_rmi { find . -name scim.rmi.server.properties | while read f; do if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/Hostname=localhost*/Hostname=172\.20\.16\.16/' $f > ${f}.1 sed 's/hostname=.*/hostname=172\.20\.16\.16/' ${f}.1 > ${f}.2 mv ${f}.2 ${f} rm -rf ${f}.1 cp ${f} ${f}.local done } function productionize_frontend_rmi { find . -name rmi.server.properties | while read f; do if [ -e ${f}.local ]; then cp ${f}.local $f fi # backup the file cp $f ${f}.local sed 's/scimHostname=localhost*/scimHostname=172\.20\.16\.16/' $f > ${f}.1 mv ${f}.1 ${f} cp ${f} ${f}.local done } function deploy_rest_client_to_snapshot { cd service/rest-client mvn deploy:deploy-file \ -Dfile=target/rest-client-1.0.jar \ -DpomFile=pom.xml \ -DrepositoryId=fluigidentity.snapshot \ -Durl=http://archiva.fluigidentity.com:8580/repository/totvslabs-release/ cd - } function deploy_idm_common_model_to_snapshot { cd idm-common-model mvn deploy:deploy-file \ -Dfile=target/idm-common-model-1.0.jar \ -DpomFile=pom.xml \ -DrepositoryId=fluigidentity.snapshot \ -Durl=http://archiva.fluigidentity.com:8580/repository/totvslabs-release/ cd - } function deploy_saml_java_toolkit_to_snapshot { cd security/protocol/saml-java-toolkit mvn deploy:deploy-file \ -Dfile=target/saml-java-toolkit-1.0.jar \ -DpomFile=pom.xml \ -DrepositoryId=fluigidentity.snapshot \ -Durl=http://archiva.fluigidentity.com:8580/repository/totvslabs-release/ cd - } function deploy_saml_java_rest_client_to_snapshot { cd security/protocol/SamlRestClient/saml-java-rest-client mvn deploy:deploy-file \ -Dfile=target/saml-java-rest-client-1.0.jar \ -DpomFile=pom.xml \ -DrepositoryId=fluigidentity.snapshot \ -Durl=http://archiva.fluigidentity.com:8580/repository/totvslabs-release/ cd - } function deploy_saml_rest_toolkit_to_snapshot { cd security/protocol/saml-rest-toolkit mvn deploy:deploy-file \ -Dfile=target/saml-rest-toolkit-1.0.war \ -DpomFile=pom.xml \ -DrepositoryId=fluigidentity.snapshot \ -Durl=http://archiva.fluigidentity.com:8580/repository/totvslabs-release/ cd - } function check_error { if [ $? -ne 0 ] ; then exit -1 fi } DATE=`date '+%Y-%m-%d-%H:%M:%S'` FI_HOME=/data/build/fluigidentity-br-prod if [ ! -e $FI_HOME ]; then mkdir -p $FI_HOME fi if [ $# -eq 1 ]; then branch=$1 #if [ -n $branch ]; then BRANCH="$branch" if [ -e $FI_HOME/$BRANCH ]; then mv $FI_HOME/$BRANCH $FI_HOME/$BRANCH-$DATE echo "backup existing folder" echo "mv $FI_HOME/$BRANCH $FI_HOME/$BRANCH-$DATE" fi #else # echo "Please enter the branch you want to build . # echo "For instance identity-1.0.5" # read branch #fi echo " building backend, frontend and security" echo "Plase wait ....." BACKEND=backend FRONTEND=frontend SECURITY=security GIT_BACKEND=git@github.com:TOTVS/${BACKEND}.git GIT_FRONTEND=git@github.com:TOTVS/${FRONTEND}.git # clone repos cd $FI_HOME/ mkdir $BRANCH && cd $BRANCH # for repo in $GIT_BACKEND $GIT_FRONTEND; do # echo "git clone -o master $repo" # git clone -b $BRANCH $repo #done git clone -b $branch $GIT_BACKEND check_error git clone -b $branch $GIT_FRONTEND check_error cd $FI_HOME/ ### rm -f latest ln -s $BRANCH latest cd $FI_HOME/latest ### BACKEND BUILD FIRST export JAVA_HOME="/opt/jdk" export MVN=/usr/local/maven/bin echo "Build all jar files," cd $FI_HOME/$BRANCH/$BACKEND $MVN/mvn clean install -Dmaven.test.skip=true check_error $MVN/mvn clean package -Dmaven.test.skip=true -Pall-jars check_error $MVN/mvn deploy -Pproduction.release -Dmaven.test.skip=true check_error productionize_backend_rmi check_error productionize_backend_scim_rmi check_error ### GRAILS BUILD JAVA_HOME=/opt/jdk check_error GRAILS=/usr/local/grails/bin cd $FI_HOME/$BRANCH/$FRONTEND/idm-cloudpass productionize_frontend_rmi check_error echo "Build frontend" $GRAILS/grails clean $GRAILS/grails refresh-dependencies $GRAILS/grails compile $GRAILS/grails war check_error ## Setting PROD ENV cd $FI_HOME/$BRANCH/$BACKEND echo "productionize keystore.server.properties" productionize_keystore_properties echo "enable search" enable_search echo "productionize server.properties" productionize_server_properties echo "productionize adsync" productionize_adsync productionize_keystore_yml echo "productionize rest" productionize_rest_yml echo "enable aws" enable_aws echo "productionize hornetQ server" productionize_hornetq cd $FI_HOME/$BRANCH echo "Pre-Packing" pre-packaging ### Make deb packing FPM=/usr/local/bin/fpm RELEASE=`echo $branch| cut -d'-' -f2` cd $FI_HOME/$BRANCH $FPM -s dir -t deb -n fluigidentity -v $RELEASE --description "Fluigidentity Software" --url 'https://www.fluigidentity.com' cloudpass echo "builds and package are done... enjoy !!!" ### cd $FI_HOME/$BRANCH/ echo "sync to local repo" copy_to_repo update-packages else echo -e "\n\nUsage: $0 {branch name}" echo -e "ex: $0 identity-1.1\n\n" fi
Python
UTF-8
711
2.859375
3
[]
no_license
import json def lambda_handler(event, context): result = exp_func(int(event['queryStringParameters']["x"]), int(event['queryStringParameters']["y"])) return { 'statusCode': 200, 'headers': { 'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Allow-Origin': '*', }, 'body': json.dumps(result) } def exp_func(x, y): if (not isinstance(x, int)) or (not isinstance(y, int)): return "please input integers" exp = bin(y) # print(exp) value = x for i in range(3, len(exp)): value = value * value if(exp[i:i+1]=='1'): value = value*x return value # print(exp_func(2, 1023))
Python
UTF-8
668
4.34375
4
[]
no_license
"""Function that return true or false if the select value is on even position in array""" def is_on_even_position(table, value): """Verify if the select value is on even position in array Returns: bool: true or false """ res_index = False for index, i in enumerate(table): if i == value: if index%2 == 0: res_index = True return res_index def main(): """Main function""" array_num = [9, 8, 7, 6, 5, 4, 3, 2, 1] ex1 = is_on_even_position(array_num, 6) ex2 = is_on_even_position(array_num, 3) print("ex1", ex1) print("ex2", ex2) if __name__ == "__main__": main()
Java
UTF-8
395
1.609375
2
[]
no_license
package com.tencent.mm.plugin.webview.ui.tools; import com.tencent.mm.plugin.webview.ui.tools.WebViewUI.23; class WebViewUI$23$29 implements Runnable { final /* synthetic */ 23 pZM; final /* synthetic */ int qaf; WebViewUI$23$29(23 23, int i) { this.pZM = 23; this.qaf = i; } public final void run() { WebViewUI.a(this.pZM.pZJ, this.qaf); } }
TypeScript
UTF-8
720
3.046875
3
[]
no_license
import { SnakeState, STATE } from "./SnakeState"; import { SnakeMoveDown } from "./SnakeMoveDown"; import SnakeMoveUp from "./SnakeMoveUp"; import { SnakeStop } from "./SnakeStop"; export class SnakeMoveRight extends SnakeState{ constructor () { super(); this.move(); console.log("state in right"); } handleInput (Snake:any, input:any) { if (input === STATE.DOWN) { Snake.state = new SnakeMoveDown(); } else if (input === STATE.UP) { Snake.state = new SnakeMoveUp(); } else if (input === STATE.STOP) { Snake.state = new SnakeStop(); } } move(){ this.speed_x = 1; this.speed_y = 0; } }
C#
UTF-8
771
3.078125
3
[]
no_license
using System; namespace HeistPart2 { public class LockSpecialist : IRobber { public string Name { get; set; } public int SkillLevel { get; set; } public int PercentageCut { get; set; } public string Type { get; set; } public int Index { get; set; } public void PerformSkill(Bank bank) { if (SkillLevel >= 50) { bank.VaultScore = bank.VaultScore - 50; Console.WriteLine($"{Name} is breaking into the vault. Vault Score has decreased by 50 points, Shhhh almost got it!"); } else if (bank.VaultScore == 0) { Console.WriteLine($"{Name} has disabled the Vault system"); } } } }
Go
UTF-8
1,447
2.640625
3
[]
no_license
package client import ( "context" "net" "github.com/lev2048/lrp/internal/conn" "github.com/lev2048/lrp/internal/utils" "github.com/sirupsen/logrus" ) type Transport struct { sc conn.Conn conn net.Conn cid []byte laddr string exit chan bool log *logrus.Logger ctx context.Context } func NewTransport(lr string, cid []byte, sc conn.Conn, ctx context.Context, log *logrus.Logger) *Transport { return &Transport{ sc: sc, cid: cid, log: log, ctx: ctx, laddr: lr, exit: make(chan bool), } } func (t *Transport) Process() (err error) { if t.conn, err = net.Dial("tcp", t.laddr); err != nil { return } else { go func() { buf := make([]byte, 1460*3) for { select { case <-t.ctx.Done(): return case <-t.exit: return default: if ln, err := t.conn.Read(buf); err != nil { utils.EncodeSend(t.sc, append([]byte{3, 0}, t.cid...)) return } else { payload := append([]byte{2}, t.cid...) payload = append(payload, buf[:ln]...) if err := utils.EncodeSend(t.sc, payload); err != nil { t.log.WithField("info", err).Warn("write to server err") return } } } } }() } return } func (t *Transport) Write(data []byte) bool { if _, err := t.conn.Write(data); err != nil { t.log.Warn("write to local error") return false } return true } func (t *Transport) Close() { close(t.exit) t.conn.Close() }
TypeScript
UTF-8
658
2.8125
3
[]
no_license
import { PermissionStore } from '../Permission'; import { Observable, of } from 'rxjs'; import { PermissionMapping } from './permission.mapping'; //this is an implementation of PermissionStore //it get current user roles //and looking in permission mapping and find the permissions of these roles export class LocalPermissionStore implements PermissionStore { LoadPermission(roles: string[]): Observable<string[]> { const perm: string[] = []; for (const key in PermissionMapping) { if (PermissionMapping[key].some(x => roles.some(y => x.toUpperCase() === y.toUpperCase()))) { perm.push(key); } } return of(perm); } }
Java
UTF-8
1,175
2.03125
2
[]
no_license
/* * (C) Copyright 2021 ESTATE REACTJS SPRING BOOT API. All Rights * * @author ngodi * @date Jun 21, 2021 * @hour 2:57:18 PM */ package com.estate.core.entity; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "user_roles") public class User_Role implements Serializable{ /** * */ private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user_id") private Long userid; @Column(name = "role_id") private Long roleid; /** * @return the userid */ public Long getUserid() { return userid; } /** * @param userid the userid to set */ public void setUserid(Long userid) { this.userid = userid; } /** * @return the roleid */ public Long getRoleid() { return roleid; } /** * @param roleid the roleid to set */ public void setRoleid(Long roleid) { this.roleid = roleid; } }
C#
UTF-8
6,791
3.21875
3
[]
no_license
using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Checklist { // fonctions qui ne marchent pas class Rotation { public GraphicsPath GetRoundRect(float X,float Y,float width,float height,float radius) { GraphicsPath gp = new GraphicsPath(); gp.AddLine(X + radius,Y,X + width - (radius * 2),Y); gp.AddArc(X + width - (radius * 2),Y,radius * 2,radius * 2,270,90); gp.AddLine(X + width,Y + radius,X + width,Y + height - (radius * 2)); gp.AddArc(X + width - (radius * 2),Y + height - (radius * 2),radius * 2,radius * 2,0,90); gp.AddLine(X + width - (radius * 2),Y + height,X + radius,Y + height); gp.AddArc(X,Y + height - (radius * 2),radius * 2,radius * 2,90,90); gp.AddLine(X,Y + height - (radius * 2),X,Y + radius); gp.AddArc(X,Y,radius * 2,radius * 2,180,90); gp.CloseFigure(); return gp; } public static Bitmap RotateImage3(Image image,float angle) { if (image == null) throw new ArgumentNullException("image"); //create a new empty bitmap to hold rotated image Bitmap rotatedBmp = new Bitmap(image.Width,image.Height); rotatedBmp.SetResolution(image.HorizontalResolution,image.VerticalResolution); //make a graphics object from the empty bitmap Graphics g = Graphics.FromImage(rotatedBmp); //Put the rotation point in the center of the image g.TranslateTransform((float)image.Width / 2,(float)image.Height / 2); //rotate the image g.RotateTransform(angle); //move the image back g.TranslateTransform(-(float)image.Width / 2,-(float)image.Height / 2); //draw passed in image onto graphics object g.DrawImage(image,new PointF(0,0)); return rotatedBmp; } public static Image RotateImage2(Image img,float rotationAngle) { //create an empty Bitmap image Bitmap bmp = new Bitmap(img.Width,img.Height); //turn the Bitmap into a Graphics object Graphics gfx = Graphics.FromImage(bmp); gfx.SmoothingMode = SmoothingMode.AntiAlias; //now we set the rotation point to the center of our image gfx.TranslateTransform((float)bmp.Width / 2,(float)bmp.Height / 2); //now rotate the image gfx.RotateTransform(rotationAngle); gfx.TranslateTransform(-(float)bmp.Width / 2,-(float)bmp.Height / 2); //set the InterpolationMode to HighQualityBicubic so to ensure a high //quality image once it is transformed to the specified size gfx.InterpolationMode = InterpolationMode.HighQualityBicubic; //now draw our new image onto the graphics object gfx.DrawImage(img,new Point(0,0)); //dispose of our Graphics object gfx.Dispose(); //return the image return bmp; } public static Image RotateImage(Image img,float rotationAngle) { //create an empty Bitmap image Bitmap bmp = new Bitmap(img.Width,img.Height); //turn the Bitmap into a Graphics object Graphics gfx = Graphics.FromImage(bmp); //now we set the rotation point to the center of our image gfx.TranslateTransform((float)bmp.Width / 2,(float)bmp.Height / 2); //now rotate the image gfx.RotateTransform(rotationAngle); gfx.TranslateTransform(-(float)bmp.Width / 2,-(float)bmp.Height / 2); //set the InterpolationMode to HighQualityBicubic so to ensure a high //quality image once it is transformed to the specified size gfx.InterpolationMode = InterpolationMode.HighQualityBicubic; //now draw our new image onto the graphics object gfx.DrawImage(img,new Point(0,0)); //dispose of our Graphics object gfx.Dispose(); //return the image return bmp; } // Return a bitmap rotated around its center. private Bitmap RotateBitmap(Bitmap bm,float angle) { // Make a bitmap to hold the rotated result. Bitmap result = new Bitmap(bm.Width,bm.Height); // Create the real rotation transformation. Matrix rotate_at_center = new Matrix(); rotate_at_center.RotateAt(angle, new PointF(bm.Width / 2f,bm.Height / 2f)); // Draw the image onto the new bitmap rotated. using (Graphics gr = Graphics.FromImage(result)) { // Use smooth image interpolation. gr.InterpolationMode = InterpolationMode.High; // Clear with the color in the image's upper left corner. gr.Clear(Color.White); //// For debugging. (Easier to see the background.) //gr.Clear(Color.LightBlue); // Set up the transformation to rotate. gr.Transform = rotate_at_center; // Draw the image centered on the bitmap. gr.DrawImage(bm,0,0); } // Return the result bitmap. return result; } private void rotation90Degres(PictureBox pb) { for (int i = 0 ; i < 90 ; i++) { pb.Image = RotateImage(pb.Image,1); System.Threading.Thread.Sleep(2); pb.Update(); } } private void rotation90Degres(object tag) { Image img = (Image)tag; for (int i = 0 ; i < 90 ; i++) { img = RotateImage(img,1); System.Threading.Thread.Sleep(10); /* treeView1.Update(); */ } } private void rotation90AntiHoraire(PictureBox pb) { for (int i = 0 ; i < 90 ; i++) { pb.Image = RotateImage(pb.Image,-1); System.Threading.Thread.Sleep(2); pb.Update(); } } private static Bitmap ResizeBitmap(Bitmap sourceBMP,int width,int height) { Bitmap result = new Bitmap(width,height); using (Graphics g = Graphics.FromImage(result)) { g.DrawImage(sourceBMP,0,0,width,height); } return result; } } }
Python
UTF-8
1,518
2.59375
3
[]
no_license
import os import conf def split(task_num,source,destdir,prefix): f = open(source,'r') split_num = task_num lst = [] for i in range(0,split_num): lst.append([]) count = 0 urls = f.readlines() total = len(urls) for r in urls: lst[count%split_num].append(r) count += 1 for i in range(0,split_num): fn = destdir+'/'+prefix+str(i+1)+'.txt' f2 = open(fn,'w') for r in lst[i]: f2.write(r) f2.close() print 'split finished' def sendTask(ips,tdir,prefix,rdest): for i in range(1,len(ips)+1): cmd = 'scp '+tdir+'/'+prefix+str(i)+'.txt'+' '+ips[i-1]+':'+rdest os.system(cmd) print 'tasks send finished' #split total urls to these clients def task_split(conf_path): config = conf.readConf(conf_path) ips = config['ips'] split_tmp = config['split_tmp'] data_file = config['data_file'] task_num = len(ips) prefix = config['split_prefix'] data_source = data_file rdest = data_file split(task_num,data_source,split_tmp,prefix) sendTask(ips,split_tmp,prefix,rdest) #split one client urls to many smaller ones to each process threads def my_task_split(conf_path): config = conf.readConf(conf_path) split_tmp = config['split_tmp'] data_file = config['data_file'] task_num = config['task_num'] prefix = config['split_prefix'] split(task_num,data_file,split_tmp,prefix)
JavaScript
UTF-8
362
3.796875
4
[]
no_license
// Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. const sumSquares = (limit) => { let sumSquare = (limit*(limit+1)*((2*limit)+1))/6 let sum = (limit*(1+100))/2; console.log(sumSquare); return Math.pow(sum,2)-sumSquare; } console.log(sumSquares(100));
PHP
UTF-8
847
2.671875
3
[ "MIT" ]
permissive
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class TodoCreateRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'title'=>'required|max:255', 'desc'=>'required|max:6000', ]; } public function messages() { return [ 'title.required'=>'Title is required!', 'desc.required'=>'Title is required!', 'title.max'=>'Title is no longger than 255 character!', 'desc.max'=>'Description too big!', ]; } }
Java
UTF-8
1,339
3.390625
3
[]
no_license
package homeworkInheritencePerson4; public class Address { private String city = " "; private String country = " "; private String state = " "; private int houseNo = 0; private int streetNo = 0; Address() { } public void showAddress() { System.out.println( getCity() + " " + getCountry() + " " + " " + getState() + " " + getHouseNo() + " " + getStreetNo()); } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getHouseNo() { return houseNo; } public void setHouseNo(int houseNo) { this.houseNo = houseNo; } public int getStreetNo() { return streetNo; } public void setStreetNo(int streetNo) { this.streetNo = streetNo; } @Override public String toString() { String res = city + " " + country + " " + " " + state + " " + houseNo + " " + streetNo; return res; } public Address(String city, String country, String state, int houseNo, int streetNo) { super(); this.city = city; this.country = country; this.state = state; this.houseNo = houseNo; this.streetNo = streetNo; } }
Markdown
UTF-8
7,786
2.734375
3
[]
no_license
一二〇 司空蕙闻言,方自点了点头,忽然足下一阵震动,巨响隆隆,连四周峰壁,都有些摇摇欲坠! 她见此情状,骇然叫道:“皇甫兄,甘兄快躲,恐怕有甚地震山崩灾变,这不是人力武功,可以抵御的呢!” 边自发话,边自拉着皇甫端、甘晓里二人,电闪身形,避往“冰心洞”口! 他们刚刚闪入“冰心古洞”,峰壁间便有些大小石块,陆续往下滚落! 司空蕙方自秀眉深锁,暗担忧虑之际,又是一阵隆隆巨响之处,反而峰壁不摇,坠石渐止。 转眼间,整座“冰心谷”,又恢复平静,甘晓星摇了摇头,含笑说道:“我还以为今日会遭遇一场地裂天崩的活埋之险,谁知竟这般雷声大,雨点小地,安然无事!” 皇甫端忽然想起一事,向司空蕙皱眉问道:“蕙妹,‘冰心洞’中虽已无事,但后洞秘道,经过这一震荡,有些地方恐支持不住了吧?” 司空蕙被皇甫端一言提醒,悚然失惊,根本来不及答话地,便向“冰心后洞”,电疾驰去。 皇甫端与甘晓星二人,随后追去,尚未看见司空蕙的倩影,便已听见这位“慧心玉女”的嘤嘤啜泣之声! 等他们到达近前,果见“迷踪甬道”业已倾圯,堵塞了通往后洞之路! 司空慧极为谨慎小心地,搬动了不少石块,但见石后有石垒积如山,知道无望再通!又复心中一酸.凄然垂泪地,向皇甫端顿足叫道:“端哥哥,你看看有多槽,从今以后,我和我姊姊真是人天永隔,无法相见了呢!” 皇甫端知她姊妹情探,心中凄苦,遂只好加以安慰,柔声劝道:“蕙妹不要难过,这桩事儿,若从两个不同角度,加以观察,悲喜便有不同!因为,你们姊妹两人,虽然人天永别,参拜无由,但姊姊法体,却也获得永远清静,不虞再有任何魔劫!” 皇甫端的这番话儿,果然把司空蕙劝慰得破涕为笑,点头说道:“端哥哥说的也对,只要我姊姊的法体,能够获得永远安静,不被魔扰,我便应该高兴,不再悲苦才是!” 甘晓星站在一旁,微笑说道:“司空姊姊既然业已想通,不再悲痛,我们就该离开此处,赶赴‘岷山’,参与‘两代英雄会’了!” 司空蕙道:“甘兄稍待片刻,我把洞中几件紧要东西,收拾收拾!” 甘晓星微笑点头,与皇甫端双双退出“冰心古洞”,在谷中散步等待。 约莫过了顿饭光阴,司空蕙便收拾好了行囊等物,走出洞府,并三人合力,移来巨石,再加上一道妥善封闭。 甘晓星一面移石,一面目光微注,发现司空蕙腰间佩着一具五色丝囊,不禁扬眉问道:“司空姊姊,你腰间所佩,就是你姊姊司空仙子,昔日威震群魔的‘如意五云囊’吗?” 司空蕙点头笑道:“甘兄眼力真高,竟认得丝毫不错!” 甘晓星微笑道:“这只囊儿之中的五件武林异宝,无不威力绝强,司空姊姊带去‘岷山大会’,足够那般凶邪恶煞,消受不起的了!” 司空蕙摇了摇头,微微叹道:“甘兄有所不知,这‘如意五云囊’中的五件奇宝之内,有三件已被我姊姊,借给友人,如今囊中只有‘冰心三叶扇,和‘如意五云轮’两件东西而已!” 甘晓星笑道:“就这两件东西,也已颇具防身御敌妙用,加上司空姊姊的绝艺神功……” 他话方至此,霍然回身,双目精芒电射地,觑定六七丈前谷径转折之处! 皇甫端与司空蕙,也同时有所发觉,双双扬眉凝目,和甘晓星注视同一所在! 甘晓星首先一抱双拳,发话说道:“请问来人是哪位武林前辈,怎不现身相见?” 谷径转折处,有人“哈哈”一笑,皇甫端听出笑声甚熟,不禁失声叫道:“上官六叔!” 果然.紫色儒衫闪处,“血泪七友”中的老六,“括苍紫裘生”上官渊,飘然走出。 皇甫端看见了上官渊,自己万死一生,含冤负屈的各种情事,立时全上心头,不禁抢前几步,叫了声“六师叔”,便自泪落如泉,拜倒在地! 上官渊含笑说道:“端儿,你沉冤大白,应该高兴才是,怎么反而如此伤感则甚?” 他一面发话,一面便命皇甫端起立,无须如此多礼。 皇甫端拭泪说道:“六师叔早知小侄,负屈含冤,但我师傅与其他师伯师叔,却未必……” 上官渊不等他往下再说,便即摇手笑道:“端儿不要如此讲法,你难道真把‘血泪七友’兄妹,全看成可以任人愚弄的懵懂糊涂之人?” 这几句话儿,把皇甫端问得好生羞赧,俊脸通红! 但他又有点奠明其妙,只好瞪着两只俊眼,向上官渊愕然凝视! 上官渊微笑说道:“我们兄妹七人,自从离开‘娄山’,便分在江湖各处,查究你所有行踪,然后再一一综合推敲研判,终于发现果有其他人物,冒你之名行恶,你师傅与你大师伯三师叔,方放心静参神功,准备‘岷山’之会,而使我与你四师叔、五师叔、七师叔等,分别在南北东西,帮助你暗查冤案!” 皇甫端听得感激师恩,忍不住地,又复心酸泪落! 上官渊继续笑道:“但蓄意害你之人,心思极巧,作事不留丝毫痕迹,使我们虽已明知你身负奇冤,却无法获得什么平反证据?直到我与‘神箫秀士’诸葛尊相遇,方由他告知一切情况,赶来替你们办理一桩大事!” 皇甫端愕然问道:“如今端儿清白已复,此间祸变亦平,司空仙子法体,永告安宁,无虞尘扰,似乎除了找寻端儿另一红妆密友陶敏姑娘,以及参与‘两代英雄会’外,好像无甚大事了呢!” 上官渊微微一笑,目光如电,向皇甫端与司空蕙的脸上,来回扫视! 皇甫端见状方始有点明白,不禁好生惭愧,耳根发热! 司空蕙更是霞生双颊,娇羞不胜! 上官渊剑眉双扬,哈哈笑道:“端儿,你前生修得多少福慧,居然皇英并美,双凤……” 话方至此,那位甘晓星业已接口笑道:“上官六叔,你既与‘神箫秀士’诸葛前辈相遇,他是否把所有有关秘密,全都告诉你了?” 上官渊点头笑道:“他当然一齐告我,包括了任何曲折离奇,哀感顽艳的情节在内!” 他一面说话,一面目注甘晓星,目光中却流露出神秘眼色! 甘晓星微笑说道:“上官六叔,既然明白一切隐情,便应该替皇甫兄及司空姊姊做主,让他们正了名分!” 上官渊含笑问道:“甘老弟,你赞成我替他们做主吗?” 甘晓星应声笑道:“明珠配仙露,威凤配样麟,像皇甫兄与司空姊姊这等天造地设的绝世良缘,哪有不为人赞同之理?” 上官渊向他看了两眼,点头笑道:“好!甘老弟既然赞成,我们就共同玉成他们这桩美事! 我来替他们做主,你来替他们作证!” 皇甫端忽然摇手叫道:“六师叔,此事不行,我……” 上官渊把脸一沉,冷然说道:“你怎么样?你难道对于司空姑娘,还不满意?” 皇甫端闻言,窘得俊脸通红,苦笑答道:“六师叔会错意了,我不是对于蕙妹有何不满,而是尚有一位红妆密友,不容辜负!” 上官渊道:“你是不是说那陶敏?”
C++
UTF-8
23,424
2.828125
3
[]
no_license
#include "VoxelChunk.h" #include "SimplexNoise\SimplexNoise.h" #include "Transvoxel.h" #include <iostream> VoxelChunk::VoxelChunk(glm::i32vec3 world) :chunkLocation(world), isEmpty(true), vertexfloatcount(0), indexcount(0), ib(nullptr), vb(nullptr) { SimplexNoise cnoise(1/30.0f,1.0f); int i, j, k; for (i = 0; i < chunksize+2; i++) { for (k = 0; k < chunksize + 2; k++) { float fractalResult = cnoise.fractal(1, (float)(i + chunkLocation.x * chunksize - 1), (float)(k + chunkLocation.z * chunksize - 1)) * 10; for (j = 0; j < chunksize + 2; j++) { if ( fractalResult > (j + chunkLocation.y * chunksize - 1)) { VoxelData[i][j][k] = 1; isEmpty = false; } else VoxelData[i][j][k] = 0; } } } if(!getisEmpty())//If not empty calculate geo data calculateGeometry(); } VoxelChunk::~VoxelChunk() { delete ib; delete vb; } void VoxelChunk::calculateGeometry() { //Create two arrays at their maximum size (reduced after number is known) float* vertexarray = new float[vertexmax]; unsigned int* indexarray = new unsigned int[indexmax]; //Counter variables for each array vertexfloatcount = 0; indexcount = 0; //3D loop variables int i, j, k; //Loop through every voxel for (i = 1; i < chunksize + 1; i++) { for (j = 1; j < chunksize + 1; j++) { for (k = 1; k < chunksize + 1; k++) { //If there's a solid block we check each face to see if it borders air if (VoxelData[i][j][k] != 0) { //Check +x if (VoxelData[i + 1][j][k] == 0)//If empty in positve X direction add face at +x { //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Triangles indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 3; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 1; indexcount++; } //Check -X if (VoxelData[i - 1][j][k] == 0)//If empty in negative X direction add face at -x { //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Triangles indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 3; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 1; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; } //Check +y if (VoxelData[i][j + 1][k] == 0)//If empty in positve Y direction add face at +Y { vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal and Color vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal and Color vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal and Color vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal and Color vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Triangles indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 3; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 1; indexcount++; } //Check -y if (VoxelData[i][j - 1][k] == 0)//If empty in negative Y direction add face at -Y { //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Triangles indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 3; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 1; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; } //Check +Z if (VoxelData[i][j][k + 1] == 0)//If empty in positve Z direction add face at +Z { //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k + 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Triangles indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 3; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 1; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; } //Check -Z if (VoxelData[i][j][k - 1] == 0)//If empty in negative Z direction add face at -Z { //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = -1.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Location vertexarray[vertexfloatcount] = (float)i - 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)j + 0.5f; vertexfloatcount++; vertexarray[vertexfloatcount] = (float)k - 0.5f; vertexfloatcount++; //Normal vertexarray[vertexfloatcount] = 1.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.0f; vertexfloatcount++; //Color vertexarray[vertexfloatcount] = 0.39f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.26f; vertexfloatcount++; vertexarray[vertexfloatcount] = 0.13f; vertexfloatcount++; //Triangles indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 3; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 4; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 2; indexcount++; indexarray[indexcount] = vertexfloatcount / vertexatributecount - 1; indexcount++; } } } } } //Create vertex buffer out of calculated data vb = new VertexBuffer(vertexarray,vertexfloatcount*sizeof(float)); //Create index buffer out of calculated data ib = new IndexBuffer(indexarray, indexcount); //Delete temp buffers delete[] vertexarray; delete[] indexarray; } int VoxelChunk::getVertexFloatCount() { return vertexfloatcount; } int VoxelChunk::getIndexCount() { return indexcount; } bool VoxelChunk::getisEmpty() { return isEmpty; } VertexBuffer* VoxelChunk::getVertexBuffer() { return vb; } IndexBuffer* VoxelChunk::getIndexBuffer() { return ib; } glm::i32vec3 VoxelChunk::getChunkLocation() { return chunkLocation; }
C
UTF-8
1,481
4.09375
4
[]
no_license
#include <wchar.h> #include <string.h> #include <stdio.h> // A string is a null-terminated array of type char, including the terminating // null byte. String-valued variables are usually declared to be pointers of // char *. Such variable do not include space for the next of a string; that // has to be stored somewhere else -- in an array variable, a string constant, // or dynamically allocated memory. It's up to you to store the address of the // address of the chosen memory space into the pointer variable. Alternatively // you can store a null pointer in the pointer variable. The mull pointer does // not point anywhere, so attempting to reference the string it points to get // an error. // A multibyte character is a sequence of one or more bytes that represents a // single character using the locale's encoding scheme; a null byte always // represents the null character. A multiple string is a string that consists // entirely of multibyte characters. In contrast, a wide string is a // null-terminated sequence of wchar_t objects. A wide-string variable is // usually declared to be a pointer of type wchar_t *, by analogy with string // variables and char *. void hello_string(void) { char *ch = "hello, world"; wchar_t *ws = L"hello, world"; printf("ch length: %lu\n", strlen(ch)); printf("ws length: %lu\n", wcslen(ws)); } int main(void) { hello_string(); return 0; } // https://www.gnu.org/software/libc/manual/html_mono/libc.html#Character-Handling
Java
GB18030
2,647
3.21875
3
[]
no_license
package csdn.bugs; import java.util.*; import java.io.*; public class ResortByDel { @SuppressWarnings("unchecked") public void ResortToTemp(String firstFile, String secondFile, String tempPath1, String tempPath2) throws IOException { // String oldPath = oldFolderPath; File f1 = new File(firstFile); File f2 = new File(secondFile); String str1 = null; String str2 = null; String string1 = null; String string2 = null; Vector vector1 = new Vector();// // Vector vector2 = new Vector();// // // boolean IsRepeat = false; try { BufferedReader reader1 = new BufferedReader(new FileReader(f1)); BufferedReader reader2 = new BufferedReader(new FileReader(f2)); while ((str1 = reader1.readLine()) != null && (str2 = reader2.readLine()) != null) { if(!vector1.contains(str1)){ vector1.add(str1); } if(!vector2.contains(str2)){ vector2.add(str2); } } reader1.close(); reader2.close(); } catch (IOException e) { e.printStackTrace(); } // дļ String newFile1 = tempPath1; String newFile2 = tempPath2; File tempFile1 = new File(newFile1); File tempFile2 = new File(newFile2); if (tempFile1.exists()) { tempFile1.delete(); } if (tempFile2.exists()) { tempFile2.delete(); } tempFile1.createNewFile(); tempFile2.createNewFile(); try { BufferedWriter writer1 = new BufferedWriter(new FileWriter( tempFile1, true)); BufferedWriter writer2 = new BufferedWriter(new FileWriter( tempFile2, true)); for (int i = 0; i < vector1.size(); i++) { str1 = (String) vector1.elementAt(i); writer1.write(str1); writer1.newLine(); writer1.flush(); } for (int i = 0; i < vector2.size(); i++) { str2 = (String) vector2.elementAt(i); writer2.write(str2); writer2.newLine(); writer2.flush(); } writer1.close(); writer2.close(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) throws IOException { String tempPath1 = "D:\\tmp\\test1.txt"; String tempPath2 = "D:\\tmp\\test2.txt"; // String sourceFolder = "D:/tmp/tmp"; String resultPath1 = "D:\\tmp\\result1.txt"; String resultPath2 = "D:\\tmp\\result2.txt"; // File tempFile = new File(tempPath); ResortByDel resort = new ResortByDel(); // resort.AllResortToTemp(sourceFolder,tempPath);//ȷŵtemp.txtȻɾ resort.ResortToTemp(tempPath1, tempPath2, resultPath1, resultPath2);// tempļȥطresultļ // resort.DelTemp(tempPath);//ɾtemp.txtתļ System.out.println("OK"); } }
Java
UTF-8
219
2.109375
2
[]
no_license
package com.fifthapp; public class MyThread1 extends Thread { static ThreadScope scope = new ThreadScope(); A a; MyThread1(A a){ this.a = a; } @Override public void run() { scope.set("AAA"); a.m1(); } }
Markdown
UTF-8
956
3.171875
3
[]
no_license
# REST Afternoon Project: https://github.com/ChesterJGreen/Music-Is-Fun ## What does REST stand for, and in simple terms what does it mean? REpresentational State Transfer This means when a RESTful API is called, the server will transfer to the client a representation of the state of the requested resource. I guess this means that you get specific information for a specific part of the requested resource. Usually in a Json form. --- ## What does Stateless mean? This essentially means that the API won't remember anything about the user. Every individual request is asking for the same information (which seems a bit convoluted but I guess it's simpler than setting up local or cloud save states and storage). --- ## What URL pattern is used when writing a RESTful API? When writing a RESTful API, I think you use the CRUD pattern. I wasn't really able to discern an answer to this question using just the article, but that might just be me.
Python
UTF-8
1,116
2.546875
3
[]
no_license
#!/usr/bin/python3 import sys import matplotlib.pyplot as plt import numpy as np from scipy.stats import gaussian_kde import seaborn as sns sns.set_palette("deep", desat=.6) sns.set_context(rc={"figure.figsize": (8, 4)}) file_mcscan = sys.argv[1] #'/data2/k821209/KimKH/Gm2Gm.collinearity.kaks' ks_array = np.array([]) for line in open(file_mcscan): if line[0] == '#': continue cell = line.strip().split('\t') fKs = float(cell[5]) ks_array = np.append(ks_array,fKs) data = ks_array density = gaussian_kde(data) xs = np.linspace(0,3,200) density.covariance_factor = lambda : .25 density._compute_covariance() aa = np.argmax(density(xs)) # find the position showing the max value print 'Ks:',round(xs[aa],3),'density:',round(density(xs)[aa],3) max_x = xs[aa] max_y = density(xs)[aa] plt.plot(xs,density(xs)) plt.annotate('Peak at Ks %f'%round(xs[aa],3), xy=(max_x, max_y), xytext=(max_x+0.3, max_y+0.1), arrowprops=dict(facecolor='black', shrink=0.05), ) plt.ylabel('Density') plt.xlabel('Ks value') plt.savefig('%s.ks_dist.png'%sys.argv[2], dpi=300) plt.show()
Java
UTF-8
2,676
2.265625
2
[]
no_license
package tw.com.miifun.popballoonfv; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; import android.util.Log; /** * Created by yhorn on 2016/2/20. */ public class ItemMoving extends DrawableMovingItem { final static private String appTag = "ItemMoving"; // debug: recycle counter static public int mBitmapRecycleCount = 0; int mResId; Bitmap mBitmap; Matrix mBitmapMatrix; public ItemMoving(Context context, int type, int x, int y, int width, int height, int screenWidth, int screenHeight ) { super(context, type, x, y, width, height, screenWidth, screenHeight); } public void setBitmap( int resid ) { if ( mBitmap != null && mResId != 0 ) { BitmapWarehouse.releaseBitmap( mResId ); mBitmapRecycleCount --; mBitmap = null; } mBitmap = BitmapWarehouse.getBitmap( mContext, resid ); if ( mBitmap != null ) { mResId = resid; } else { mResId = 0; Log.w(appTag, "error, BitmapWarehouse.getBitmap return null"); } } // public abstract method public boolean draw( Canvas canvas ) { Rect srcRect = null; Rect destRect; Bitmap bp; bp = getCurrentBitmap(); if ( canvas == null ) { Log.w(appTag, "error, holder is null"); return false; } if ( mX > mScreenWidth || mX + mWidth < 0 || mY > mScreenHeight || mY + mHeight < 0 ) { // Log.v(appTag, "ignore draw, outside the screen"); return false; } if ( mX < 0 || mX + mWidth > mScreenWidth || mY < 0 || mY + mHeight > mScreenHeight ) { srcRect = getSrcRect( bp.getWidth(), bp.getHeight() ); if ( srcRect == null ) { return false; } } destRect = getDestRect(); // Log.v( appTag, "drawBitmap bp " + bp + " x:" + mX + " y:" + mY + " w:" + mWidth + " h:" + mHeight ); if ( mBitmapMatrix == null ) { canvas.drawBitmap(bp, srcRect, destRect, null); } else { canvas.drawBitmap(bp, mBitmapMatrix, null); } return true; } public Bitmap getCurrentBitmap() { return mBitmap; } public void destroy() { // Log.v( appTag, "destroy" ); if ( mBitmap != null && mResId != 0 ) { BitmapWarehouse.releaseBitmap( mResId ); mResId = 0; mBitmapRecycleCount--; } } }
C++
UTF-8
425
2.921875
3
[]
no_license
# include<iostream.h> # include<conio.h> void main() { clrscr(); int d; cout<<"Enter no. of week's day(1-7): "; cin>>d; if(d=1) cout<<"Monday"; else if(d=2) cout<<"Tuesday"; else if(d=3) cout<<"Wednesday"; else if(d=4) cout<<"Thursday"; else if(d=5) cout<<"Friday"; else if(d=6) cout<<"Saturday"; else if(d=7) cout<<"Sunday"; getch(); }
Java
UTF-8
483
2.890625
3
[]
no_license
package top.tinn.Over200.Problem_1266; public class Solution { public int minTimeToVisitAllPoints(int[][] points) { if (points.length < 2){ return 0; } int ans = 0; for (int i = 1; i < points.length; i++){ int dx = Math.abs(points[i][0] - points[i - 1][0]); int dy = Math.abs(points[i][1] - points[i - 1][1]); ans = ans + Math.min(dx, dy) + Math.abs(dx - dy); } return ans; } }
TypeScript
UTF-8
677
2.71875
3
[ "ISC" ]
permissive
import { Breakpoint } from '/styles/breakpoints' import { Spacing } from '/styles/spacings' type AsymCol = { col: Col above?: Breakpoint gutter?: Spacing } export type Col = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 export type ColItem = { content: React.ReactElement className?: string aboveMobile?: StripedAsymCol aboveTablet?: StripedAsymCol aboveDesktop?: StripedAsymCol } export type Row = { className?: string firstCol: ColItem secondCol?: ColItem thirdCol?: ColItem fourthCol?: ColItem fifthCol?: ColItem } export type StripedAsymCol = Omit<AsymCol, 'above'> export type StripedColWithBp = StripedAsymCol & { above?: Breakpoint }
C
UTF-8
297
3.796875
4
[]
no_license
#include<stdio.h> int main() { int Counter= 1, Count; printf("How many natural numbers you want to print?"); scanf("%d", &Count); printf("The natural numbers up to %d are", Count); while (Counter <= Count) { printf (" %d", Counter); Counter = Counter + 1; } printf ("."); }
Markdown
UTF-8
1,004
3.59375
4
[]
no_license
# Navigation - [Navigation](#navigation) - [Links](#links) - [Solution 1 暴力法](#solution-1-%e6%9a%b4%e5%8a%9b%e6%b3%95) # Links 1. https://leetcode.com/problems/rotated-digits/ 2. https://leetcode-cn.com/problems/rotated-digits/ # Solution 1 暴力法 ```python class Solution: def rotatedDigits(self, N: int) -> int: skips = '347' remains = '2569' count = 0 for val in range(1, N + 1): string = str(val) count += all(c not in skips for c in string) and any(c in remains for c in string) return count ``` --- ```python # 集合 class Solution: def rotatedDigits(self, N: int) -> int: valid = {'2','5','6','9'} invalid = {'3','4','7'} # 180度反转后不是一个数字 result = 0 for num in range(1, N+1): s = set(str(num)) if s & invalid: continue elif s & valid: result += 1 return result ```
Python
UTF-8
531
2.84375
3
[ "MIT" ]
permissive
class Base(): def __init__(self, id, *args, **kwargs): self.id = id super().__init__(*args, **kwargs) @classmethod def get_id(cls, id, type='state'): """ Parameters ---------- id : str type : str, default='state' Type of object associated with the moments distribution. Returns ------- id dictionary : dict Dictionary identifier. """ return {'dist-cls': cls.__name__, 'dist-id': id, 'type': type}
Markdown
UTF-8
2,001
2.859375
3
[ "CC-BY-4.0", "MIT" ]
permissive
--- title: "Turn on auto geocoding (Dynamics 365 Field Service) | MicrosoftDocs" description: Learn how to turn on auto geocoding in Dynamics 365 Field Service ms.custom: - dyn365-fieldservice ms.date: 09/08/2022 ms.topic: article author: jshotts ms.author: jasonshotts --- # Turn on auto geocoding to calculate estimated travel time Dynamics 365 Field Service needs latitude and longitude values for service account records to estimate travel times when scheduling a work order to a resource. With the **Auto Geo Code Addresses** setting, the system attempts to automatically add the coordinates based on the address provided for the service account. > [!IMPORTANT] > To use the schedule board booking functionality, geocoding, and location services, you need to turn on maps. > > For more information, see [Connect to maps](field-service-maps-address-locations.md#connect-to-maps). ## Enable on automatic geocoding 1. Open the **Field Service** app. 1. Change to the **Settings** area and go to **Administration**, and then choose **Field Service Settings**. 1. In **Other** tab, set **Auto Geo Code Addresses** to **Yes**. :::image type="content" source="media/auto-geo-code-addresses-setting.png" alt-text="Screenshot of Field Service Settings with Auto Geo Code Addresses setting enabled."::: 1. Select **Save**. > [!NOTE] > When geocoding an address, the only street field used is **Street1**. Additional information like apartment number in **Street2** and **Street3** will be ignored. ## Geocode the address on a record 1. Open a work order or a service account. 2. Ensure the address is accurate. 3. On the top command bar, select **Geo Code**. :::image type="content" source="media/geo-code-control.png" alt-text="Screenshot of the Geo Code control on an Account view."::: 4. On the map dialog box, make sure you have the correct address, and then select **Change**. [!INCLUDE[footer-include](../includes/footer-banner.md)]
JavaScript
UTF-8
23,055
2.59375
3
[ "MIT" ]
permissive
 var hideCalendarTimer = new Array(); function calendarTimer(objname){ this.objname = objname; this.timers = new Array(); } function toggleCalendar(objname, auto_hide, hide_timer){ var div_obj = document.getElementById('div_'+objname); if(div_obj != null){ if (div_obj.style.visibility=="hidden") { div_obj.style.visibility = 'visible'; document.getElementById(objname+'_frame').contentWindow.adjustContainer(); //auto hide if inactivities with calendar after open if(auto_hide){ if(hide_timer < 3000) hide_timer = 3000; //put default 3 secs prepareHide(objname, hide_timer); } }else{ div_obj.style.visibility = 'hidden'; } } } function showCalendar(objname){ var div_obj = document.getElementById('div_'+objname); if(div_obj != null){ div_obj.style.visibility = 'visible'; document.getElementById(objname+'_frame').contentWindow.adjustContainer(); } } function hideCalendar(objname){ var div_obj = document.getElementById('div_'+objname); if(div_obj != null){ div_obj.style.visibility = 'hidden'; } } function prepareHide(objname, timeout){ cancelHide(objname); var timer = setTimeout(function(){ hideCalendar(objname) }, timeout); var found = false; for(i=0; i<this.hideCalendarTimer.length; i++){ if(this.hideCalendarTimer[i].objname == objname){ found = true; this.hideCalendarTimer[i].timers[this.hideCalendarTimer[i].timers.length] = timer; } } if(!found){ var obj = new calendarTimer(objname); obj.timers[obj.timers.length] = timer; this.hideCalendarTimer[this.hideCalendarTimer.length] = obj; } } function cancelHide(objname){ for(i=0; i<this.hideCalendarTimer.length; i++){ if(this.hideCalendarTimer[i].objname == objname){ var timers = this.hideCalendarTimer[i].timers; for(n=0; n<timers.length; n++){ clearTimeout(timers[n]); } this.hideCalendarTimer[i].timers = new Array(); break; } } } function setValue(objname, d){ //compare if value is changed var changed = (document.getElementById(objname).value != d) ? true : false; updateValue(objname, d); var dp = document.getElementById(objname+"_dp").value; if(dp) toggleCalendar(objname); checkPairValue(objname, d); //calling calendar_onchanged script if(document.getElementById(objname+"_och").value != "" && changed) calendar_onchange(objname); var date_array = document.getElementById(objname).value.split("-"); tc_submitDate(objname, date_array[2], date_array[1], date_array[0]); } function updateValue(objname, d){ document.getElementById(objname).value = d; var dp = document.getElementById(objname+"_dp").value; if(dp == true){ var date_array = d.split("-"); var inp = document.getElementById(objname+"_inp").value; if(inp == true){ document.getElementById(objname+"_day").value = padString(date_array[2].toString(), 2, "0"); document.getElementById(objname+"_month").value = padString(date_array[1].toString(), 2, "0"); document.getElementById(objname+"_year").value = padString(date_array[0].toString(), 4, "0"); //check for valid day tc_updateDay(objname, date_array[0], date_array[1], date_array[2]); }else{ if(date_array[0] > 0 && date_array[1] > 0 && date_array[2] > 0){ //update date pane var myDate = new Date(); myDate.setFullYear(date_array[0],(date_array[1]-1),date_array[2]); var dateFormat = document.getElementById(objname+"_fmt").value; var dateTxt = myDate.format(dateFormat); }else var dateTxt = "Select Date"; document.getElementById("divCalendar_"+objname+"_lbl").innerHTML = dateTxt; } } } function tc_submitDate(objname, dvalue, mvalue, yvalue){ var obj = document.getElementById(objname+'_frame'); var year_start = document.getElementById(objname+'_year_start').value; var year_end = document.getElementById(objname+'_year_end').value; var dp = document.getElementById(objname+'_dp').value; var da1 = document.getElementById(objname+'_da1').value; var da2 = document.getElementById(objname+'_da2').value; var sna = document.getElementById(objname+'_sna').value; var aut = document.getElementById(objname+'_aut').value; var frm = document.getElementById(objname+'_frm').value; var tar = document.getElementById(objname+'_tar').value; var inp = document.getElementById(objname+'_inp').value; var fmt = document.getElementById(objname+'_fmt').value; var dis = document.getElementById(objname+'_dis').value; var pr1 = document.getElementById(objname+'_pr1').value; var pr2 = document.getElementById(objname+'_pr2').value; var prv = document.getElementById(objname+'_prv').value; var path = document.getElementById(objname+'_pth').value; var spd = document.getElementById(objname+'_spd').value; var spt = document.getElementById(objname+'_spt').value; var och = document.getElementById(objname+'_och').value; var str = document.getElementById(objname+'_str').value; var rtl = document.getElementById(objname+'_rtl').value; var wks = document.getElementById(objname+'_wks').value; var int = document.getElementById(objname+'_int').value; var hid = document.getElementById(objname+'_hid').value; var hdt = document.getElementById(objname+'_hdt').value; obj.src = path+"calendar_form.php?objname="+objname.toString()+"&selected_day="+dvalue+"&selected_month="+mvalue+"&selected_year="+yvalue+"&year_start="+year_start+"&year_end="+year_end+"&dp="+dp+"&da1="+da1+"&da2="+da2+"&sna="+sna+"&aut="+aut+"&frm="+frm+"&tar="+tar+"&inp="+inp+"&fmt="+fmt+"&dis="+dis+"&pr1="+pr1+"&pr2="+pr2+"&prv="+prv+"&spd="+spd+"&spt="+spt+"&och="+och+"&str="+str+"&rtl="+rtl+"&wks="+wks+"&int="+int+"&hid="+hid+"&hdt="+hdt; obj.contentWindow.submitNow(dvalue, mvalue, yvalue); } function tc_setDMY(objname, dvalue, mvalue, yvalue){ var obj = document.getElementById(objname); obj.value = yvalue + "-" + mvalue + "-" + dvalue; tc_submitDate(objname, dvalue, mvalue, yvalue); } function tc_setDay(objname, dvalue){ var obj = document.getElementById(objname); var date_array = obj.value.split("-"); //check if date is not allow to select if(!isDateAllow(objname, dvalue, date_array[1], date_array[0]) || !checkSpecifyDate(objname, dvalue, date_array[1], date_array[0])){ //alert("This date is not allow to select"); restoreDate(objname); }else{ if(isDate(dvalue, date_array[1], date_array[0])){ tc_setDMY(objname, dvalue, date_array[1], date_array[0]); }else document.getElementById(objname+"_day").selectedIndex = date_array[2]; } checkPairValue(objname, obj.value); //compare if value is changed var changed = (document.getElementById(objname).value != d) ? true : false; //calling calendar_onchanged script if(document.getElementById(objname+"_och").value != "" && changed) calendar_onchange(objname); } function tc_setMonth(objname, mvalue){ var obj = document.getElementById(objname); var date_array = obj.value.split("-"); //check if date is not allow to select if(!isDateAllow(objname, date_array[2], mvalue, date_array[0]) || !checkSpecifyDate(objname, date_array[2], mvalue, date_array[0])){ //alert("This date is not allow to select"); restoreDate(objname); }else{ if(document.getElementById(objname+'_dp').value && document.getElementById(objname+'_inp').value){ //update 'day' combo box date_array[2] = tc_updateDay(objname, date_array[0], mvalue, date_array[2]); } if(isDate(date_array[2], mvalue, date_array[0])){ tc_setDMY(objname, date_array[2], mvalue, date_array[0]); }else document.getElementById(objname+"_month").selectedIndex = date_array[1]; } checkPairValue(objname, obj.value); //compare if value is changed var changed = (document.getElementById(objname).value != d) ? true : false; //calling calendar_onchanged script if(document.getElementById(objname+"_och").value != "" && changed) calendar_onchange(objname); } function tc_setYear(objname, yvalue){ var obj = document.getElementById(objname); var date_array = obj.value.split("-"); //check if date is not allow to select if(!isDateAllow(objname, date_array[2], date_array[1], yvalue) || !checkSpecifyDate(objname, date_array[2], date_array[1], yvalue)){ //alert("This date is not allow to select"); restoreDate(objname); }else{ if(document.getElementById(objname+'_dp').value && document.getElementById(objname+'_inp').value){ //update 'day' combo box date_array[2] = tc_updateDay(objname, yvalue, date_array[1], date_array[2]); } if(isDate(date_array[2], date_array[1], yvalue)){ tc_setDMY(objname, date_array[2], date_array[1], yvalue); }else document.getElementById(objname+"_year").value = date_array[0]; } checkPairValue(objname, obj.value); //compare if value is changed var changed = (document.getElementById(objname).value != d) ? true : false; //calling calendar_onchanged script if(document.getElementById(objname+"_och").value != "" && changed) calendar_onchange(objname); } function yearEnter(e){ var characterCode; if(e && e.which){ //if which property of event object is supported (NN4) e = e; characterCode = e.which; //character code is contained in NN4's which property }else{ e = event; characterCode = e.keyCode; //character code is contained in IE's keyCode property } if(characterCode == 13){ //if Enter is pressed, do nothing return true; }else return false; } // Declaring valid date character, minimum year and maximum year var minYear=1900; var maxYear=2100; function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function is_leapYear(year){ return (year % 4 == 0) ? !(year % 100 == 0 && year % 400 != 0) : false; } function daysInMonth(month, year){ var days = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); return (month == 2 && year > 0 && is_leapYear(year)) ? 29 : days[month-1]; } /* function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31; if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } */ function isDate(strDay, strMonth, strYear){ /* //bypass check date strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (strMonth.length<1 || month<1 || month>12){ alert("Please enter a valid month") return false } if (strDay.length<1 || day<1 || day>31 || day > daysInMonth(month, year)){ alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){ alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false }*/ return true } function isDateAllow(objname, strDay, strMonth, strYear){ var da1 = parseInt(document.getElementById(objname+"_da1").value); var da2 = parseInt(document.getElementById(objname+"_da2").value); var da1_ok = !isNaN(da1); var da2_ok = !isNaN(da2); strDay = parseInt(parseFloat(strDay)); strMonth = parseInt(parseFloat(strMonth)); strYear = parseInt(parseFloat(strYear)); if(strDay>0 && strMonth>0 && strYear>0){ if(da1_ok || da2_ok){ // calculate the number of seconds since 1/1/1970 for the date (equiv to PHP strtotime()) var date = new Date(strYear, strMonth-1, strDay); da2Set = date.getTime()/1000; // alert(da1+"\n"+da2+"\n"+strDay+"\n"+strMonth+"\n"+strYear+"\n"+da2Set); // return true if the date is in range if ((!da1_ok || da2Set >= da1) && (!da2_ok || da2Set <= da2)){ return true; }else{ var dateFormat = document.getElementById(objname+"_fmt").value; if (da1_ok){ date.setTime(da1*1000); da1Str = date.format(dateFormat); } if (da2_ok){ date.setTime(da2*1000); da2Str = date.format(dateFormat); } if (!da1_ok) alert("Please choose a date before " + da2Str); else if (!da2_ok) alert("Please choose a date after " + da1Str); else alert("Please choose a date between\n"+ da1Str + " and " + da2Str); return false; } } } return true; //always return true if date not completely set } function restoreDate(objname){ //get the store value var storeValue = document.getElementById(objname).value; var storeArr = storeValue.split('-', 3); //set it document.getElementById(objname+'_day').value = storeArr[2]; document.getElementById(objname+'_month').value = storeArr[1]; document.getElementById(objname+'_year').value = storeArr[0]; } //---------------------------------------------------------------- //javascript date format function thanks to // http://jacwright.com/projects/javascript/date_format // // some modifications to match the calendar script //---------------------------------------------------------------- // Simulates PHP's date function Date.prototype.format = function(format) { var returnStr = ''; var replace = Date.replaceChars; for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (replace[curChar]) { returnStr += replace[curChar].call(this); } else { returnStr += curChar; } } return returnStr; }; Date.replaceChars = { shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], longMonths: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'], shortDays: ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัส', 'ศุกร์', 'เสาร์', 'อาทิตย์'], longDays: ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัส', 'ศุกร์', 'เสาร์', 'อาทิตย์'], // Day d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); }, D: function() { return Date.replaceChars.shortDays[this.getDay()]; }, j: function() { return this.getDate(); }, l: function() { return Date.replaceChars.longDays[this.getDay()]; }, N: function() { return this.getDay() + 1; }, S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); }, w: function() { return this.getDay(); }, z: function() { return "Not Yet Supported"; }, // Week W: function() { return "Not Yet Supported"; }, // Month F: function() { return Date.replaceChars.longMonths[this.getMonth()]; }, m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); }, M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; }, n: function() { return this.getMonth() + 1; }, t: function() { return "Not Yet Supported"; }, // Year L: function() { return "Not Yet Supported"; }, o: function() { return "Not Supported"; }, Y: function() { return this.getFullYear(); }, y: function() { return ('' + this.getFullYear()).substr(2); }, // Time a: function() { return this.getHours() < 12 ? 'am' : 'pm'; }, A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; }, B: function() { return "Not Yet Supported"; }, g: function() { return this.getHours() % 12 || 12; }, G: function() { return this.getHours(); }, h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); }, H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); }, i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); }, s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); }, // Timezone e: function() { return "Not Yet Supported"; }, I: function() { return "Not Supported"; }, O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; }, T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;}, Z: function() { return -this.getTimezoneOffset() * 60; }, // Full Date/Time c: function() { return "Not Yet Supported"; }, r: function() { return this.toString(); }, U: function() { return this.getTime() / 1000; } }; function padString(stringToPad, padLength, padString) { if (stringToPad.length < padLength) { while (stringToPad.length < padLength) { stringToPad = padString + stringToPad; } }else {} /* if (stringToPad.length > padLength) { stringToPad = stringToPad.substring((stringToPad.length - padLength), padLength); } else {} */ return stringToPad; } function tc_updateDay(objname, yearNum, monthNum, daySelected){ //var totalDays = (monthNum > 0) ? daysInMonth(monthNum, yearNum) : 31; var totalDays = (monthNum > 0 && yearNum > 0) ? daysInMonth(monthNum, yearNum) : ((monthNum > 0) ? daysInMonth(monthNum, 2008) : 31); var dayObj = document.getElementById(objname+"_day"); //var prevSelected = dayObj.value; if(dayObj.options[0].value == 0 || dayObj.options[0].value == "") dayObj.length = 1; else dayObj.length = 0; for(d=1; d<=totalDays; d++){ var newOption = document.createElement("OPTION"); newOption.text = d; newOption.value = d; dayObj.options[d] = new Option(newOption.text, padString(newOption.value, 2, "0")); } if(daySelected > totalDays) dayObj.value = padString(totalDays, 2, "0"); else dayObj.value = padString(daySelected, 2, "0"); return dayObj.value; } function checkPairValue(objname, d){ var dp1 = document.getElementById(objname+"_pr1").value; var dp2 = document.getElementById(objname+"_pr2").value; var this_value = document.getElementById(objname).value; //var this_time2 = Date.parse(this_value)/1000; //var this_time1 = Date.parse(this_value.replace(/-/g,'/'))/1000; var this_dates = this_value.split('-'); var this_time = new Date(this_dates[0], this_dates[1]-1, this_dates[2]).getTime()/1000; //implementing dp2 if(dp1 != "" && document.getElementById(dp1) != null){ //imply to date_pair1 //set date pair value to date selected document.getElementById(dp1+"_prv").value = d; var dp1_value = document.getElementById(dp1).value; //var dp1_time = Date.parse(dp1_value)/1000; //var dp1_time = Date.parse(dp1_value.replace(/-/g,'/'))/1000; var dp1_dates = dp1_value.split('-'); var dp1_time = new Date(dp1_dates[0], dp1_dates[1]-1, dp1_dates[2]).getTime()/1000; if(this_time < dp1_time){ //set self date pair value to null document.getElementById(objname+"_prv").value = ""; tc_submitDate(dp1, "00", "00", "0000"); }else{ //var date_array = document.getElementById(dp1).value.split("-"); tc_submitDate(dp1, dp1_dates[2], dp1_dates[1], dp1_dates[0]); } } //implementing dp1 if(dp2 != "" && document.getElementById(dp2) != null){ //imply to date_pair2 //set date pair value to date selected document.getElementById(dp2+"_prv").value = d; var dp2_value = document.getElementById(dp2).value; //var dp2_time = Date.parse(dp2_value)/1000; //var dp2_time = Date.parse(dp2_value.replace(/-/g,'/'))/1000; var dp2_dates = dp2_value.split('-'); var dp2_time = new Date(dp2_dates[0], dp2_dates[1]-1, dp2_dates[2]).getTime()/1000; if(this_time > dp2_time){ //set self date pair value to null document.getElementById(objname+"_prv").value = ""; tc_submitDate(dp2, "00", "00", "0000"); }else{ //var date_array = document.getElementById(dp2).value.split("-"); tc_submitDate(dp2, dp2_dates[2], dp2_dates[1], dp2_dates[0]); } } } function checkSpecifyDate(objname, strDay, strMonth, strYear){ var spd = document.getElementById(objname+"_spd").value; var spt = document.getElementById(objname+"_spt").value; //alert(spd); var sp_dates; if(typeof(JSON) != "undefined"){ sp_dates = JSON.parse(spd); }else{ //only array is assume for now if(spd != "" && spd.length > 2){ var tmp_spd = spd.substring(2, spd.length-2); //alert(tmp_spd); var sp_dates = tmp_spd.split("],["); for(i=0; i<sp_dates.length; i++){ //alert(sp_dates[i]); var tmp_str = sp_dates[i]; //.substring(1, sp_dates[i].length-1); if(tmp_str == "") sp_dates[i] = new Array(); else sp_dates[i] = tmp_str.split(","); } }else sp_dates = new Array(); } /* for(i=0; i<sp_dates.length; i++){ for(j=0; j<sp_dates[i].length; j++){ alert(sp_dates[i][j]); } } */ var found = false; for (var key in sp_dates[2]) { if (sp_dates[2].hasOwnProperty(key)) { this_date = new Date(sp_dates[2][key]*1000); //alert(sp_dates[2][key]+","+this_date.getDate()); if(this_date.getDate() == parseInt(parseFloat(strDay)) && (this_date.getMonth()+1) == parseInt(parseFloat(strMonth))){ found = true; break; } } } if(!found){ for (var key in sp_dates[1]) { if (sp_dates[1].hasOwnProperty(key)) { this_date = new Date(sp_dates[1][key]*1000); //alert(sp_dates[2][key]+","+this_date.getDate()); if(this_date.getDate() == parseInt(parseFloat(strDay))){ found = true; break; } } } } if(!found){ var choose_date = new Date(strYear, strMonth-1, strDay); var choose_time = choose_date.getTime()/1000; for (var key in sp_dates[0]) { if (sp_dates[0].hasOwnProperty(key)) { //alert(key + " -> " + p[key]); if(choose_time == sp_dates[0][key]){ found = true; break; } } } } //alert("aa:"+found); switch(spt){ case 0: default: //date is disabled if(found){ alert("You cannot choose this date"); return false; } break; case 1: //other dates are disabled if(!found){ alert("You cannot choose this date"); return false; } break; } return true; } function urldecode (str) { return decodeURIComponent((str + '').replace(/\+/g, '%20')); } function calendar_onchange(objname){ //you can modify or replace the code below var fc = document.getElementById(objname+"_och").value; //alert("Date has been set to "+obj.value); eval(urldecode(fc)); } function focusCalendar(objname){ var obj = document.getElementById("container_"+objname); if(obj != null){ obj.style.zIndex = 999; } } function unFocusCalendar(objname, zidx){ var obj = document.getElementById("container_"+objname); if(obj != null){ obj.style.zIndex = zidx; } }
Java
UTF-8
1,115
2.203125
2
[]
no_license
package com.cars.management.dao; import com.cars.management.model.Car; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.PathVariable; import java.util.List; /** * Created by GJW on 2017/5/29. */ @Mapper public interface CarDAO { String TABLE_NAME = " car "; String INSERT_FILEDS = " brand, name, seatnum, gearbox "; String SELECT_FILEDS = "id, " + INSERT_FILEDS; @Insert( {" insert into ", TABLE_NAME ,"(", INSERT_FILEDS, " ) values (#{brand}, #{name}, #{seatnum}, #{gearbox})"}) int addCar(Car car); @Select( {" select " + SELECT_FILEDS + " from " + TABLE_NAME + " where id = #{id}"}) Car selectCar(@Param("id") int id); List<Car> selectCars(@Param("offset") int offset, @Param("limit") int limit); @Update({" update " + TABLE_NAME + " set brand = #{brand} , name = #{name} , seatnum = #{seatnum}, gearbox = #{gearbox} where id = #{id} "}) void update(Car car); @Delete({"delete from " + TABLE_NAME + " where id = #{id}"}) void delete(@Param("id") int id); }
Java
UTF-8
11,673
1.554688
2
[ "Apache-2.0" ]
permissive
/* * Copyright 2018-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.data.elasticsearch.core.index; import static org.assertj.core.api.Assertions.*; import static org.skyscreamer.jsonassert.JSONAssert.*; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; import java.time.LocalDate; import java.util.Set; import org.json.JSONException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.DateFormat; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.Mapping; import org.springframework.data.elasticsearch.annotations.Setting; import org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveIndexOperations; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.lang.Nullable; /** * @author Peter-Josef Meisch */ @SpringIntegrationTest public abstract class ReactiveIndexOperationsIntegrationTests { @Autowired private ReactiveElasticsearchOperations operations; @Autowired private IndexNameProvider indexNameProvider; private ReactiveIndexOperations indexOperations; @BeforeEach void setUp() { indexNameProvider.increment(); indexOperations = operations.indexOps(IndexCoordinates.of(indexNameProvider.indexName())); } @Test @Order(java.lang.Integer.MAX_VALUE) void cleanup() { operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete().block(); } @Test // DATAES-678 void shouldCreateIndexOpsForIndexCoordinates() { ReactiveIndexOperations indexOperations = operations.indexOps(IndexCoordinates.of("some-index-name")); assertThat(indexOperations).isNotNull(); } @Test // DATAES-678 void shouldCreateIndexOpsForEntityClass() { ReactiveIndexOperations indexOperations = operations.indexOps(Entity.class); assertThat(indexOperations).isNotNull(); } @Test // DATAES-678 void shouldCreateIndexForName() { indexOperations.create() // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); } @Test // DATAES-678 void shouldCreateIndexForEntity() { ReactiveIndexOperations indexOps = operations.indexOps(Entity.class); indexOps.create() // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); // check the settings from the class annotation indexOps.getSettings().as(StepVerifier::create).consumeNextWith(settings -> { assertThat(settings.get("index.number_of_replicas")).isEqualTo("2"); assertThat(settings.get("index.number_of_shards")).isEqualTo("3"); assertThat(settings.get("index.refresh_interval")).isEqualTo("4s"); }).verifyComplete(); } @Test // DATAES-678 void shouldCreateIndexWithGivenSettings() { var index = new Settings() // .append("number_of_replicas", 3) // .append("number_of_shards", 4)// .append("refresh_interval", "5s"); var requiredSettings = new Settings().append("index", index); indexOperations.create(requiredSettings) // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); indexOperations.getSettings().as(StepVerifier::create).consumeNextWith(settings -> { var flattened = settings.flatten(); assertThat(flattened.get("index.number_of_replicas")).isEqualTo("3"); assertThat(flattened.get("index.number_of_shards")).isEqualTo("4"); assertThat(flattened.get("index.refresh_interval")).isEqualTo("5s"); }).verifyComplete(); } @Test // DATAES-678 void shouldCreateIndexWithAnnotatedSettings() { ReactiveIndexOperations indexOps = operations.indexOps(EntityWithAnnotatedSettingsAndMappings.class); indexOps.create() // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); indexOps.getSettings().as(StepVerifier::create).consumeNextWith(settings -> { assertThat(settings.get("index.number_of_replicas")).isEqualTo("0"); assertThat(settings.get("index.number_of_shards")).isEqualTo("1"); assertThat(settings.get("index.analysis.analyzer.emailAnalyzer.tokenizer")).isNotNull(); assertThat(settings.get("index.analysis.analyzer.emailAnalyzer.tokenizer")).isEqualTo("uax_url_email"); }).verifyComplete(); } @Test // DATAES-678 public void shouldCreateIndexUsingServerDefaultConfiguration() { indexOperations.create() // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); // check the settings from the class annotation indexOperations.getSettings().as(StepVerifier::create).consumeNextWith(settings -> { assertThat(settings.get("index.number_of_replicas")).isEqualTo("1"); assertThat(settings.get("index.number_of_shards")).isEqualTo("1"); }).verifyComplete(); } @Test // DATAES-678 void shouldDeleteIfItExists() { indexOperations.create().block(); indexOperations.delete() // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); } @Test // DATAES-678 void shouldReturnFalseOnDeleteIfItDoesNotExist() { indexOperations.delete() // .as(StepVerifier::create) // .expectNext(false) // .verifyComplete(); } @Test // DATAES-678 void shouldReturnExistsTrueIfIndexDoesExist() { indexOperations.create().block(); indexOperations.exists() // .as(StepVerifier::create) // .expectNext(true) // .verifyComplete(); } @Test // DATAES-678 void shouldReturnExistsFalseIfIndexDoesNotExist() { indexOperations.exists() // .as(StepVerifier::create) // .expectNext(false) // .verifyComplete(); } @Test // DATAES-678 void shouldCreateMappingForEntityFromProperties() { String expected = """ { "properties":{ "text": { "type": "text" }, "publication-date": { "type": "date", "format": "basic_date" } } } """; // indexOperations.createMapping(Entity.class) // .as(StepVerifier::create) // .assertNext(document -> { try { assertEquals(expected, document.toJson(), false); } catch (JSONException e) { fail("", e); } }) // .verifyComplete(); } @Test // DATAES-678 void shouldCreateMappingForEntityFromMappingAnnotation() { String expected = """ { "properties": { "email": { "type": "text", "analyzer": "emailAnalyzer" } } } """; // indexOperations.createMapping(EntityWithAnnotatedSettingsAndMappings.class) // .as(StepVerifier::create) // .assertNext(document -> { try { assertEquals(expected, document.toJson(), false); } catch (JSONException e) { fail("", e); } }) // .verifyComplete(); } @Test // DATAES-678 void shouldCreateMappingBoundEntity() { ReactiveIndexOperations indexOps = operations.indexOps(Entity.class); String expected = """ { "properties":{ "text": { "type": "text" }, "publication-date": { "type": "date", "format": "basic_date" } } } """; // indexOps.createMapping() // .as(StepVerifier::create) // .assertNext(document -> { try { assertEquals(expected, document.toJson(), false); } catch (JSONException e) { fail("", e); } }) // .verifyComplete(); } @Test // DATAES-678 void shouldPutAndGetMapping() { ReactiveIndexOperations indexOps = operations.indexOps(Entity.class); String expected = """ { "properties":{ "text": { "type": "text" }, "publication-date": { "type": "date", "format": "basic_date" } } } """; // indexOps.create() // .then(indexOps.putMapping()) // .then(indexOps.getMapping()) // .as(StepVerifier::create) // .assertNext(document -> { try { assertEquals(expected, document.toJson(), false); } catch (JSONException e) { fail("", e); } }).verifyComplete(); } @Test // DATAES-864 void shouldCreateAlias() { AliasActions aliasActions = new AliasActions(); aliasActions.add(new AliasAction.Add(AliasActionParameters.builder() .withIndices(indexOperations.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build())); indexOperations.create().flatMap(success -> { if (success) { return indexOperations.alias(aliasActions); } else { return Mono.just(false); } }).as(StepVerifier::create).expectNext(true).verifyComplete(); } @Test // DATAES-864 void shouldGetAliasData() { AliasActions aliasActions = new AliasActions(); aliasActions.add(new AliasAction.Add(AliasActionParameters.builder() .withIndices(indexOperations.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build())); assertThat(indexOperations.create().block()).isTrue(); assertThat(indexOperations.alias(aliasActions).block()).isTrue(); indexOperations.getAliases("aliasA") // .as(StepVerifier::create) // .assertNext(aliasDatas -> { // Set<AliasData> aliasData = aliasDatas.get(indexOperations.getIndexCoordinates().getIndexName()); assertThat(aliasData.stream().map(AliasData::getAlias)).containsExactly("aliasA"); }) // .verifyComplete(); } @Document(indexName = "#{@indexNameProvider.indexName()}") @Setting(shards = 3, replicas = 2, refreshInterval = "4s") static class Entity { @Nullable @Id private String id; @Nullable @Field(type = FieldType.Text) private String text; @Nullable @Field(name = "publication-date", type = FieldType.Date, format = DateFormat.basic_date) private LocalDate publicationDate; @Nullable public String getId() { return id; } public void setId(@Nullable String id) { this.id = id; } @Nullable public String getText() { return text; } public void setText(@Nullable String text) { this.text = text; } @Nullable public LocalDate getPublicationDate() { return publicationDate; } public void setPublicationDate(@Nullable LocalDate publicationDate) { this.publicationDate = publicationDate; } } @Document(indexName = "#{@indexNameProvider.indexName()}") @Setting(settingPath = "/settings/test-settings.json") @Mapping(mappingPath = "/mappings/test-mappings.json") static class EntityWithAnnotatedSettingsAndMappings { @Nullable @Id private String id; @Nullable public String getId() { return id; } public void setId(@Nullable String id) { this.id = id; } } }
Markdown
UTF-8
1,584
4.09375
4
[]
no_license
# Polymorphism #### A concept related to the object oriented approach of programming. Polymorphism is one of the core concepts in OOP languages, it describes the concept that different classes can be used with same interface. Each of these classes can provide its own implementation of the interface. If a method sometimes referred to as an interface is overridden in another class it is said to be polymorphic. This means it can be used to produce different results through the same method. [**devops_student**](devops_student.py) **[Parent/ Base Class]** * **Attributes** * current_grade `private` * current_trainer `public` * **Methods** * print_details `public` * change_current_grade `private` [**student_data**](student_data.py) **[Child/ Derived Class]** * **Methods** * print_details `public` Here the method `print_details` has been made polymorphic as it has been overridden and using a for loop printed out for both classes. It comes out different showing that the class is using polymorphism. Two classes that can be iterated and provide outputs for each method call through a polymorphic variable such as instance are known as polymorphic methods. ```python Ross = StudentData(90, "Hulk Hagen") John = DevOpsStudent(70, "Billy bog-man") for instance in (Ross, John): print(instance) print(instance.print_details()) ``` The output for this would be different for each instance, but essentially this for loop doesn't care what is in the `print_details()` it just knows they are in both classes. Therefore they can both be accessed this way.
Python
UTF-8
1,350
3.4375
3
[ "Apache-2.0" ]
permissive
from vectors import * # Given a line with coordinates 'start' and 'end' and the # coordinates of a point 'pnt' the proc returns the shortest # distance from pnt to the line and the coordinates of the # nearest point on the line. # # 1 Convert the line segment to a vector ('line_vec') # 2 Create a vector connecting start to pnt ('pnt_vec'). # 3 Find the length of the line vector ('line-len'). # 4 Convert line_vec to a unit vector ('line_unitvec'). # 5 Scale pnt_vec by line_len ('pnt_vec_scaled'). # 6 Get the dot product of line_unitvec and pnt_vec_scaled ('t'). # 7 Ensure t is in the range 0 to 1 # 8 Use to get the nearest location on the line to the end # of vector pnt_vec_scaled ('nearest') # 9 Calculate the distance from nearest to pnt_vec_scaled. # 10 Translate nearest back to the start/end line. # Malcolm Kesson 16 Dec 2012 def pnt2line(pnt, start, end): line_vec = vector(start, end) pnt_vec = vector(start, pnt) line_len = length(line_vec) line_unitvec = unit(line_vec) pnt_vec_scaled = scale(pnt_vec, 1.0/line_len) t = dot(line_unitvec, pnt_vec_scaled) if t < 0.0: t = 0.0 elif t > 1.0: t = 1.0 nearest = scale(line_vec, t) dist = distance(nearest, pnt_vec) nearest = add(nearest, start) return (dist, nearest) #-------------------------------------------------------
PHP
UTF-8
593
2.734375
3
[]
no_license
<?php class Spectra_Library_Database_Connection_Provider_MySql extends Spectra_Library_Database_Connection_Provider_Abstract{ const DEFAULT_PORT = 3306; const DEFAULT_HOST = 'localhost'; public function __construct($db_name, $db_user = '', $db_pass = '', $db_host = self::DEFAULT_HOST, $db_port = self::DEFAULT_PORT) { parent::__construct($db_name, $db_user, $db_pass, $db_host, $db_port); // DOCS: http://ca.php.net/manual/en/ref.pdo-mysql.connection.php $this->setType('mysql')->setDsn("mysql:dbname=$db_name;host=$db_host"); } }
C#
UTF-8
2,293
2.75
3
[]
no_license
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MAPMA.EscRef; using MAPMA.Model; namespace MAPMA.ServiceLayer { class EscServices { public List<EscapeRoom> GetAllForOwner() { IEscapeRoom_Services Service = new MAPMA.EscRef.EscapeRoom_ServicesClient(); var escapeRooms = Service.GetAllForOwner(); return GetClintsideEscapeRooms(escapeRooms); } public EscapeRoom GetForOwner(int ER_ID) { EscRef.IEscapeRoom_Services Service = new EscRef.EscapeRoom_ServicesClient(); try { var escapeRooms = Service.GetForOwner(ER_ID); EscapeRoom es; es = GetClientsideOneEscapeRoom(escapeRooms); return es; } catch (NullReferenceException NE) { Console.WriteLine(NE); Console.ReadLine(); return null; } } private EscapeRoom GetClientsideOneEscapeRoom(ServiceLayer.EscRef.EscapeRoom escapeRoom) { EscapeRoom es; es = new EscapeRoom { CleanTime = escapeRoom.cleanTime, Description = escapeRoom.description, EscapeRoomID = escapeRoom.escapeRoomID, MaxClearTime = escapeRoom.maxClearTime, Name = escapeRoom.name, Price = escapeRoom.price, Rating = escapeRoom.rating }; return es; } private List<EscapeRoom> GetClintsideEscapeRooms(IEnumerable<ServiceLayer.EscRef.EscapeRoom> escapeRooms) { List<EscapeRoom> foundEsc = new List<EscapeRoom>(); EscapeRoom es; foreach (var ER in escapeRooms) { es = new EscapeRoom { CleanTime = ER.cleanTime, Description = ER.description, EscapeRoomID = ER.escapeRoomID, MaxClearTime = ER.maxClearTime, Name = ER.name, Price = ER.price, Rating = ER.rating }; foundEsc.Add(es); } return foundEsc; } } }
C++
UTF-8
3,187
2.609375
3
[]
no_license
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDebug> void MainWindow::creatChart() { chartView = new QChartView(this); chart = chartView->chart(); chart->setTitle("Data Display Chart"); chartView->setChart(chart); this->setCentralWidget(chartView); series0 = new QLineSeries(); series0->setName("Data"); chart->addSeries(series0); axisX = new QValueAxis; axisX->setRange(0,100); axisX->setLabelFormat("%d"); //图例的格式 %d为十进制显示 axisX->setTitleText("times"); axisY = new QValueAxis; axisY->setRange(0,10); axisY->setLabelFormat("%d"); //图例的格式 %d为十进制显示 axisY->setTitleText("value"); chart->addAxis(axisY,Qt::AlignLeft); chart->addAxis(axisX, Qt::AlignBottom); series0->attachAxis(axisX); //把数据添加到坐标轴上 series0->attachAxis(axisY); } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); //创建串口对象 connect(ui->USART,&QToolButton::clicked,[=](){ QStringList m_serialPortName; foreach(const QSerialPortInfo &info,QSerialPortInfo::availablePorts()) { m_serialPortName << info.portName(); qDebug()<<"serialPortName:"<<info.portName(); serial.setPortName(info.portName()); } //设置波特率 serial.setBaudRate(QSerialPort::Baud115200); //设置数据位数 serial.setDataBits(QSerialPort::Data8); //设置奇偶校验 serial.setParity(QSerialPort::NoParity); //设置停止位 serial.setStopBits(QSerialPort::OneStop); //设置流控制 serial.setFlowControl(QSerialPort::NoFlowControl); if(!serial.open(QIODevice::ReadWrite)) { qDebug()<<"USART OPEN FAIL"; ui->lineEdit->setText("USART OPEN FAIL"); return ; } ui->lineEdit->setText("USART OPEN SUCCESSFUL"); }); connect(ui->OpenUsart,&QToolButton::clicked,[=](){ creatChart(); connect(&serial, &QSerialPort::readyRead, this, &MainWindow::serialPort_readyRead); }); } void MainWindow::serialPort_readyRead() { //从接收缓冲区中读取数据 qreal buffer = serial.readAll().toFloat(); qreal intv=1,y; static qreal t=0; static qreal old_y, new_y; //从界面中读取以前收到的数据 qDebug()<<"Data:"<<buffer; qreal cur_x_min = axisX->min(); qreal cur_x_max = axisX->max(); qreal cur_y_min = axisY->min(); qreal cur_y_max = axisY->max(); new_y=buffer; series0->append(t,new_y); t+=intv; if(t >=cur_x_max ) { axisX->setRange(cur_x_min + 1, cur_x_max + 1);//图形向左平移1 } if(new_y >=cur_y_max) { y = new_y-old_y; axisY->setRange(cur_y_min, cur_y_max + y);//图形向左平移1 } else if(new_y<=cur_y_min) { y = old_y-new_y; axisY->setRange(cur_y_min - y, cur_y_max);//图形向左平移1 } old_y=new_y; } MainWindow::~MainWindow() { delete ui; }
Java
UTF-8
2,150
2.84375
3
[]
no_license
package com.example.mipro.netschool.Diary; import android.support.annotation.NonNull; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import static com.example.mipro.netschool.MainActivity.SOCKET; public class Week { private static final SimpleDateFormat sdf = new SimpleDateFormat("d.M.yyyy"); private final Calendar monday; private final Calendar sunday; public Week(Calendar monday1) { monday = copy(monday1); setFirstMillis(monday); sunday = copy(monday); sunday.add(Calendar.DATE, 6); setLastMillis(sunday); } @Override public String toString() { return sdf.format(monday.getTime()) + " - " + sdf.format(sunday.getTime()); } public boolean dayInWeek(Calendar day) { return day.getTimeInMillis() >= monday.getTimeInMillis() && day.getTimeInMillis() <= sunday.getTimeInMillis(); } public Week getNextWeek() { Calendar nextMonday = copy(monday); nextMonday.add(Calendar.DATE, 7); return new Week(nextMonday); } public ArrayList<Quest> getQuests() { return SOCKET.getTasksAndMarks(monday, 0); } public Calendar getDay(int i) { Calendar day = copy(monday); day.add(Calendar.DATE, i % 7); return day; } @NonNull public static Calendar copy(Calendar c) { Calendar cc = Calendar.getInstance(); cc.setTimeInMillis(c.getTimeInMillis()); return cc; } @NonNull public static void setFirstMillis(Calendar c) { c.set(Calendar.AM_PM, Calendar.AM); c.set(Calendar.HOUR, 0); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } @NonNull public static void setLastMillis(Calendar c) { c.set(Calendar.AM_PM, Calendar.PM); c.set(Calendar.HOUR, 11); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); c.set(Calendar.MILLISECOND, 999); } }
Markdown
UTF-8
1,021
2.875
3
[ "MIT" ]
permissive
--- layout: page title: Về chúng tôi subtitle: Sáng tạo tương lai --- Chúng tôi là những người đam mê công nghệ luôn tìm tòi nghiên cứu để cung cấp các giải pháp cho khách hàng. Chúng tôi cung cấp các giải pháp cho mọi lĩnh vực khi có các vấn đề hãy liên hệ chúng tôi chúng tôi sẽ giải quyết chúng: - Cung cấp các giải pháp về điện: - Điện gia dụng - Điện thông minh bạn hoàn toàn có thề quản lý được thiết bị từ xa - Cung cấp các giải pháp về mạng: xây dựng hệ thống mạng, cung cấp thiết bị mạng - Các giải pháp quản lý bán hàng và quảng bá thương hiệu - Phần mềm quản lý bán hàng - Thiết kế nhận diện thương hiệu - Thiết kế website quảng bá hình ảnh công ty Khi bạn cần gì? Khi bạn có vấn đề gì hãy liên hệ với chúng tôi. Sẽ có giải pháp cho các các vấn đề của bạn.
Shell
UTF-8
347
3.078125
3
[]
no_license
#!/bin/bash # Docker setup echo "Setting up Docker for aws ec2!" sudo apt-get upgrade sudo apt-get update sudo apt-get install docker.io sudo groupadd docker sudo usermod -aG docker ubuntu # replace ubuntu by whatever your username is # logout and log back in echo "NOW LOG OUT OF YOUR SHELL, LOG BACK IN AND TYPE - $ docker run hello-world"
SQL
UTF-8
425
3.390625
3
[]
no_license
select tb_produtos.nome, tb_produtos.preco, tb_marcas.nome from tb_produtos inner join tb_marcas on tb_marcas.id = tb_produtos.marca_id -- where tb_marcas.nome like "%Nike%" -- and tb_produtos.preco < 50.00 -- tras tudo com o valor a baixo do escolhido -- and tb_produtos.nome = "meias" -- tras so um nome escolhido where tb_produtos.nome = "meias" -- tras tudo com varios nomes escolhido or tb_produtos.nome = "tenis"
JavaScript
UTF-8
2,111
2.6875
3
[]
no_license
// Instantiate empty objects. var Instagram = {}; var my_tags = []; (function(){ function filter_by_tag(photos){ var dog_photos=[]; $.each(photos.data, function(index, photo){ try { for (i=0; i<photo.tags.length; i++) { console.log(photo.tags[i]); if (my_tags.indexOf(photo.tags[i]) >= 0 && dog_photos.indexOf(photo) === -1) { dog_photos.push(photo); } } } catch(err) { console.warn("photo won't load", photo.images.standard_resolution.url); } }) toScreen(dog_photos); } function toScreen(photos){ $.each(photos, function(index, photo){ // Undefined function toTemplate, takes // the photo object and returns markup // ready for display. if (index === 0) { try{ $('div.carousel-inner').append('<div class="item active"><img width=750 src='+ photo.images.standard_resolution.url + ' alt="Dog 1"></div>'); }catch(err){ console.warn("photo won't load", photo.images.standard_resolution.url); } } else { try{ $('div.carousel-inner').append('<div class="item"><img width=800 class="full-screen-image" src='+ photo.images.standard_resolution.url + ' alt="Dog 1"></div>'); }catch(err){ console.warn("photo won't load", photo.images.standard_resolution.url); } } }); $('.carousel').carousel(); } function search(tags){ my_tags = tags; var malina_id = '12764357'; var ida_id = '180860648'; var id_to_use = malina_id; var url = "https://api.instagram.com/v1/users/" + id_to_use + "/media/recent?callback=?&client_id=aaf7cad994bd4ef293ed4ab24f2f6627"; // + tag + "/media/recent?callback=?&client_id=aaf7cad994bd4ef293ed4ab24f2f6627"; // $.ajax({ // type: 'GET', // url: url, // dataType: 'jsonp', // async: false, // contentType: "application/json", // success: function(data) { // alert("hi"); // } // }); $.getJSON(url, filter_by_tag); } Instagram.search = search; })();
C#
UTF-8
734
3.40625
3
[]
no_license
using System; class Program { static void Main() { double rekord = double.Parse(Console.ReadLine()); double razstoqnie = double.Parse(Console.ReadLine()); double vremeZaPluvane1M = double.Parse(Console.ReadLine()); double rezultat = (razstoqnie * vremeZaPluvane1M); double zabavqne = Math.Floor(razstoqnie / 15) * 12.5; double kraenRezultat = rezultat + zabavqne; if (rekord <= kraenRezultat) { Console.WriteLine($"No, he failed! He was {kraenRezultat - rekord:f2} seconds slower."); } else { Console.WriteLine($"Yes, he succeeded! The new world record is {kraenRezultat:f2} seconds."); } } }
C++
UTF-8
3,043
3.21875
3
[]
no_license
#include "classroomcontroller.h" //Constructor ClassRoomController::ClassRoomController(QDomNode *classroomsNode) { m_classroomsNode=classroomsNode; m_classrooms=m_classroomsNode->childNodes (); } //Methods //********************************************************** //**** The add method just add a node, not the students **** //********************************************************** bool ClassRoomController::add(ClassRoom classRoom, QDomElement classroomXml) { //Add the id and title attributes classroomXml.setAttribute ("id", classRoom.getId ()); classroomXml.setAttribute ("title",classRoom.getTitle ()); //Add the element to the node this->m_classroomsNode->appendChild (classroomXml); //Update the childNodes this->m_classrooms=this->m_classroomsNode->childNodes (); return true; } bool ClassRoomController::update(ClassRoom classRoom) { //Get the element in the tree for(int i=0; i<this->m_classrooms.length (); i++) { if(this->m_classrooms.item (i).toElement ().attribute ("id").toInt ()==classRoom.getId ()) { QDomElement updateElem(this->m_classrooms.item (i).toElement ()); updateElem.setAttribute ("title",classRoom.getTitle ()); return true; } } return false; } bool ClassRoomController::remove(int id) { //Parameters QDomNode rmNode; //Get the child corresponding to id for(int i=0; i<this->m_classrooms.length (); i++) { if(this->m_classrooms.item (i).toElement ().attribute ("id",0).toInt ()==id) { rmNode=m_classrooms.item (i); break; } } //Remove the node from the tree if(!this->m_classroomsNode->removeChild (rmNode).isNull ()) { //Update the node list this->m_classrooms=this->m_classroomsNode->childNodes (); return true; } return false; } ClassRoom* ClassRoomController::query(int id) { //Get the element corresponding to id for(int i=0; i<this->m_classrooms.length (); i++) { if(this->m_classrooms.item (i).toElement ().attribute ("id",0).toInt ()==id) { QDomElement classroomXml=this->m_classrooms.item (i).toElement (); return new ClassRoom(classroomXml.attribute ("id",0).toInt (),classroomXml.attribute ("title")); } } return NULL; } QList<ClassRoom *> ClassRoomController::queryAll() { //Create a new QList QList<ClassRoom *> classrooms; //Fill in the QList for(int i=0; i<this->m_classrooms.length (); i++) { classrooms.push_back (new ClassRoom(this->m_classrooms.item (i).toElement ().attribute ("id",0).toInt (), this->m_classrooms.item (i).toElement ().attribute ("title"))); } //Return the QList return classrooms; } bool ClassRoomController::isValidId(int id) { //Verify all the ids for(int i=0; i<this->m_classrooms.length (); i++) { if(this->m_classrooms.item (i).toElement ().attribute ("id",0).toInt ()==id) { return true; } } return false; }